How Work With Statements In Meteor Template
I like to work with meteor, but I have a problem I can't find a solution for. In the template file I have this code:
Klussen
Solution 1:
Spacebars (meteor's templating library), much like Handlebars (that it is based on) doesn't execute arbitrary expressions like, say, angular.js's templates.
If you change the statement you're trying to write into a helper method, like so (feel free to pick a better name!):
<templatename="klussenboard"><h2>Klussen</h2><divclass="klussenboard">
{{#each klus}}
{{#if isEnabled}}
<li><aclass="startlink"href="#"><imgsrc="/images/starten.png"></a></li>
{{/if}}
{{/each}}
</div></template>
You could then define the isEnabled helper in any client side .js file - say, client/klussenboard.js
like so:
Template.item.isEnabled = function() {
returnthis.status == 1;
}
So, this
, in helper functions is
This assumes that you are in a context where status
is a variable (which, based on your question, you are)
This would then reactively update whenever the status
variable changes.
Post a Comment for "How Work With Statements In Meteor Template"