Information about a parent for loop.

PropertiesTypeDescription
firstbooleanReturns true if the current iteration is the first. Returns false if not.
lastbooleanReturns true if the current iteration is the last. Returns false if not.
indexnumberThe 1-based index of the current iteration.
index0numberThe 0-based index of the current iteration.
lengthnumberThe total number of iterations in the loop.
rindexnumberThe 1-based index of the current iteration, in reverse order.
rindex0numberThe 0-based index of the current iteration, in reverse order.
{
  "first":true,
  "last":false,
  "index":1,
  "index0":0,
  "rindex":4,
  "rindex0":3,
  "length":4
}

use the forloop object

{% for i in (1..5) %}
  {% if forloop.length > 0 %}
    {{ i }}{% unless forloop.last %},{% endunless %}
  {% endif %}
{% endfor %}
1, 2, 3, 4, 5