increment
Creates a new variable, with a default value of 0, that's increased by 1 with each subsequent call.
Variables that are declared with increment
are unique to the layout, template,
or section file that they're created in. However, the variable is shared across
snippets included in the file.
Similarly, variables that are created with increment
are independent from those created with assign
and capture
. However, increment
and decrement
share
variables.
Syntax
{% increment variable_name %}
variable_name
The name of the variable being incremented.
{% increment variable %}
{% increment variable %}
{% increment variable %}
{% increment variable %}
{% increment variable %}
{% increment variable %}
Output
0
1
2
Was this page helpful?