increment
Adds one to a number. Sugar for | plus: 1.
{% assign page = page | increment %}Syntax
{{ value | increment }}Parameter
Description
value
The number to add one to
Return Value
Returns the value plus one. Identical to | plus: 1.
Examples
Advance a page cursor in a loop:
{% assign page = 1 %}
{% while has_next_page %}
{% http url: "https://api.example.com/orders?page=" | append: page as res %}
{% assign has_next_page = res.body.has_more %}
{% assign page = page | increment %}
{% endwhile %}Count matches:
Notes
Exactly
| plus: 1, including its coercion: non-numeric input yieldsNaN. Cast first withintegerif the input may be textNot the same as the
{% increment %}tag. The filter returns a new value and leaves the variable alone; the tag adds one to the variable in place and outputs nothing:See also:
decrement,plus, the{% increment %}tag
Last updated