Spacebars continues the philosophy of Mustache and Handlebars, which are not logical template languages. That's why even simple logic fits best in a controller, not a template.
However, you can define a custom helper block that performs a logical and .
<template name="ifand"> {{#if arg1}} {{#if arg2}} {{> Template.contentBlock}} {{else}} {{> Template.elseBlock}} {{/if}} {{else}} {{> Template.elseBlock}} {{/if}} </template>
Call as:
{{#ifand arg1="foo" arg2="bar"}}
You can also learn about passing variables to templates .
In the general case ( and among an arbitrary number of arguments) you will want to register a global template helper:
Template.registerHelper('and', function () { var args = Array.prototype.slice.call(arguments, 0, -1);
Call as:
{{#if and 1 "foo" 3 'bar' param="test"}} True {{else}} False {{/if}}
source share