forloop
Information about a parent for loop.
Properties | Type | Description |
---|---|---|
first | boolean | Returns true if the current iteration is the first. Returns false if not. |
last | boolean | Returns true if the current iteration is the last. Returns false if not. |
index | number | The 1-based index of the current iteration. |
index0 | number | The 0-based index of the current iteration. |
length | number | The total number of iterations in the loop. |
rindex | number | The 1-based index of the current iteration, in reverse order. |
rindex0 | number | The 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
Updated over 1 year ago