if
Render content when a condition is true.
Syntax
1{% if condition %}...{% elseif other %}...{% else %}...{% endif %}Usage
- The first condition that is true decides which content is shown.
- Add
elseifto check another condition, orelsefor content to show when all conditions are false. Both are optional. - Close the block with
endif.
True and false
- Conditions treat
false,null,undefined, an empty string,0, and an empty array as false. Other values are treated as true.
Example
Open in Playground| Data | |
|---|---|
| Template | |
| Output | |