A basic set of logic helpers for Blaze.
Most of the helpers take any number of arguments, which are iterated over and compared with the value of the previous one, until the relevant condition is no longer met.
The helpers and
and or
return a value instead of a boolean, which can then be used directly in the template.
Returns the last truthy argument.
Returns the first truthy argument.
Returns whether all arguments are strictly equal.
The is
helper can be used to mimic a switch
statement:
{{#if is status 'ok'}}
<span>OK</span>
{{else}}{{#if is status 'maybe'}}
<span>Maybe</span>
{{else}}
<span>Nope</span>
{{/if}}{{/if}}
Returns whether each argument is greater than the next.
Returns whether each argument is less than the next.
Returns whether the array contains all the following arguments.
Returns the second or third argument, depending on the first.
The helpers may be advantageously used with the dalgard:jade
package, which allows this parenthesis syntax:
if is(name 'Paul')
span.instrument Bass
Choosing between one of two classes:
i.icon(class=tern(isFiltered 'filter' 'world')