Glasnost Help and Documentation
Developers
Templates
TAL and METAL
TAL
TAL Statements: repeat variable
TAL Statements: repeat variable
An iteration object variable is automatically set in a repeat statement. Its name is repeat_ followed by the name of the variable used.
This variable contains the following attributes:
- index: repetition number, starting from 0.
- number: repetition number, starting from 1.
- even: true if index is even (0, 2, ...).
- odd: true if index is odd (1, 3, ...).
- start: true for the first element.
- end: true for the last element.
- length: list length, number of repetitions.
- letter: repetition number as a lower-case letter (a, b, ...).
- Letter: repetition number as an upper-case letter (A, B, ...).
- roman: lower-case roman numeral repetion number (i, ii, iii, iv, ...).
- Roman: upper-case roman numeral repetion number (I, II, III, IV, ...).
and two methods, intented for use with sorted lists:
- first
- last
Example
<ul> <li tal:repeat="author currentObject.authorsSet"> <span tal:replace="repeat_author.roman">i</span>. <span tal:replace="author.name">Name</span> </li> </ul>
results in something like this:
<ul> <li>i. Emmanuel</li> <li>ii. Frederic</li> <li>iii. Odile</li> <li>iv. Benjamin</li> </ul>