The #if _else helper allows an if/then argument.
{{#if field}}expr{{else}}expr{{/if}}
If the argument in the {{#if field}} is true, then it prints the value from the context. If the argument is false (either undefined, null, " ", 0, or [ ] ), then the block prints the else condition.
Important
Do not use spaces in this expression.
The following logical operators may be used for building an argument or placing arguments inside expressions.
|
if |
If a specified condition is true, this specifies a block of code to be executed If the condition is false, another block of code can be executed. {{#if data.name}}{{data.name}}{{/if}}
|
|---|---|
|
if...else |
This statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions, and will execute a block of code if a specified condition is true. {{#if Name}}{{Name}}{{else}}{{/if}}
|
|
else |
Specifies a block of code to be executed if the same condition is false. |
|
else if |
Specifies a new condition to test if the first condition is false. |
|
compare |
Compares two values using logical operators. {{#compare field operator field}} expr {{else}} expr {{/compare}}
|
|
each |
{{#each data.identity-profiles}} {{vid}} {{/each}}
|
|
if...compare |
{{#if data.name}}{{#compare data.name "!="
""}}{{data.name}}{{else}}{{/compare}}{{/if}}
|