Many programming languages support the notion of a "for" loop. In the most simple use case one could give, a for loop is a way to repeatedly execute a piece of code n times.
Technically a for loop advances through a sequence (e.g. all odd numbers, all even numbers, every nth number, etc), giving the programmer greater control over the seed value (or "index") of each iteration through the loop.
- var (optional)
If assigned, the current 'index' of the loop is assigned to this template variable.
- from (optional; default "0")
Identifies the starting number for the loop.
Identifies the ending number for the loop. Either 'to' or 'end' must be specified.
- step (optional; default "1")
Provides the amount to increment the loop counter.
- glue (optional)
If specified, this string is added inbetween each block of the loop.
Within the tag, the following variables are assigned:
Assigned 1 when the loop is in the first iteration.
Assigned 1 when the loop is in the last iteration.
Assigned 1 when the loop index is odd, 0 when it is even.
Assigned 1 when the loop index is even, 0 when it is odd.
Holds the current loop index value, even if the 'var' attribute has been given.
Tracks the number of times the loop has run (starts at 1).
<mt:For from="2" to="10" step="2" glue=","><$mt:Var name="__index__"$></mt:For>