I currently want to write if statements included condition expression such as if id > 3
in spacebar template. Please help me.
Blaze.registerHelper('gt', function (a, b) {
return a > b;
});
{{if gt id 3}}
<!-- do the thing you want when id > 3 -->
{{else}}
<!-- do the thing you want when id <= 3 -->
{{/if}}
3 Likes
Thanks for your answer, but I wonder where the first code section are placed at.
Anywhere in a js file in your client
folder. I put things like this in a file called blaze-helpers.js
.
1 Like
There are some packages on atmosphere that have built-in helper functions. Example: https://atmospherejs.com/ostrio/templatehelpers
1 Like