Meteor + Blaze - If else statement -
looking @ using blaze guide, seems blaze supports {{#if}}
, {{else}}
statements, have't seen examples of if-else statement. supported in blaze? or have additional if block inside else block, can ugly.
i tried {{else if}}
, gave error.
{{#if en}}{{text.en}}{{else if tc}}{{text.tc}}{{/if}}
spacebars uses same control flow structure handlebars answer same this one. in case:
{{#if en}} {{text.en}} {{else}} {{#if tc}} {{text.tc}} {{/if}} {{/if}}
side note - 1 of nice things jade supports else if
.
sometimes better alternative move logic helper this:
template.mytemplate.helpers({ textvalue: function() { if (this.en) { return this.text.tc; } else if (this.tc) { return this.text.tc; } } });
<template name="mytemplate"> <p>{{textvalue}}</p> </template>
Comments
Post a Comment