Docs »

Developer Guide »

Scripting »

Loops

For

Arrays can be iterated with for loops:



{% set list_of_names = ["Jeff", "Dan", "Darren"] %}
{% for name in list_of_names %}
* {{name}}
{% endfor %}


* Jeff
* Dan
* Darren

A variable defined within a loop is not accessible outside of it. You can first define a variable before using it in the loop to change this.

Ranges

Loop through a range of values with ..:



{% for n in 1..5 %}
{{n}}...
{% endfor %}


1...
2...
3...
4...
5...