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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -