Skip to main content

decrement

Creates a new variable, with a default value of -1, that's decreased by 1 with each subsequent call.

Variables that are declared with decrement 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 decrement are independent from those created with assign and capture. However, decrement and increment share variables.

Syntax

{% decrement variable_name %}
variable_name

The name of the variable being decremented.

{% decrement variable %}
{% decrement variable %}
{% decrement variable %}

Output

-1
-2
-3
Was this page helpful?