v1.9.1
Creates a new number variable, and increases its value by one every time it is called. The first value is 0.
Input
1 | {% increment my_counter %} |
Output
1 | 0 |
Variables created through the increment tag are independent from variables created through assign or capture.
In the example below, a variable named “var” is created through assign. The increment tag is then used several times on a variable with the same name. Note that the increment tag does not affect the value of “var” that was created through assign.
Input
1 | {% assign var = 10 %} |
Output
1 | 0 |