forloop
Information about a parent for loop.
Only exists in the for loop.
Properties
Returns true if the current iteration is the first. Returns false if not.
The 1-based index of the current iteration.
The 0-based index of the current iteration.
Returns true if the current iteration is the last. Returns false if not.
The total number of iterations in the loop.
The parent forloop object.If the current for loop isn't nested inside another for loop, then null is returned.Use the parentloop property.
The 1-based index of the current iteration, in reverse order.
The 0-based index of the current iteration, in reverse order.
Example
{{#var arr = "one,two,three" | split(",") /}}
{{#for item in arr}}
- {{ forloop.index }} {{ item }}
{{/for}}
Nested loops
{{#var arr1 = "one,two,three" | split(",") /}}
{{#var arr2 = "four,five,six" | split(",") /}}
{{#for item1 in arr1}}
- parent: {{ forloop.index }} {{ item1 }}
{{#for item2 in arr2}}
- nested: {{ forloop.index }} {{ item2 }} parent: {{forloop.parentloop.index}}
{{/for}}
{{/for}}
Was this article helpful to you?