...
- The expression is executed in the context of the focus object (but may reference other variables)
- Whitespace may be present in the tags, and is not significant.
- the else tag is optional
- {% elsif expression %} is also allowed
Loop
Note: Loop is deprecated in favor of the For control flow
The loop control tag is
{% loop var in expression %}
{{ var.expression }}
{% endloop %}
- The loop will run once for each object returned by the expression
- The loop variable is available to expressions using the named parameter
- Whitespace may be present in the tags, and is not significant.
For
The for control tag is
{% for var in expression %} {{ var.expression }} {% endfor %}
- The for loop will run once for each object returned by the expression
- The for loop variable is available to expressions using the named parameter
- Whitespace may be present in the tags, and is not significant.
Else
The else tag specifies a fallback for a for loop which has no elements
{% for var in expression %} {{ var.expression }}
{% else %}
The collection is empty. {% endfor %}
Include
The include control tag works like this:
...