For the complete documentation index, see llms.txt. This page is also available as Markdown.

decrement

Subtracts one from a number. Sugar for | minus: 1.

{% assign remaining = remaining | decrement %}

Syntax

{{ value | decrement }}
Parameter
Description

value

The number to subtract one from

Return Value

Returns the value minus one. Identical to | minus: 1.

Examples

Count down remaining retries:

{% assign retries = 3 %}
{% while retries > 0 %}
  {% http url: endpoint, method: "GET" as res %}
  {% if res.ok %}{% break %}{% endif %}
  {% assign retries = retries | decrement %}
{% endwhile %}

Reduce stock in a payload:

Notes

  • Exactly | minus: 1, including its coercion: non-numeric input yields NaN. Cast first with integer if the input may be text

  • Not the same as the {% decrement %} tag. The filter returns a new value and leaves the variable alone; the tag subtracts one from the variable in place and outputs nothing

  • See also: increment, minus, the {% decrement %} tag

Last updated