@@ -1337,7 +1337,10 @@ TAL commands are:
13371337 </tr>
13381338
13391339 The example would iterate over the sequence of users returned by
1340- "user/list" and define the local variable "u" for each entry.
1340+ "user/list" and define the local variable "u" for each entry. Using
1341+ the repeat command creates a new variable called "repeat" which you
1342+ may access to gather information about the iteration. See the section
1343+ below on `the repeat variable`_.
13411344
13421345**tal:replace="expression"**
13431346 Replace this tag with the result of the expression. For example::
@@ -1912,6 +1915,34 @@ or the python expression::
19121915
19131916 templates[name].macros[macro_name]
19141917
1918+ The repeat variable
1919+ ~~~~~~~~~~~~~~~~~~~
1920+
1921+ The repeat variable holds an entry for each active iteration. That is, if
1922+ you have a ``tal:repeat="user db/users"`` command, then there will be a
1923+ repeat variable entry called "user". This may be accessed as either::
1924+
1925+ repeat/user
1926+ python:repeat['user']
1927+
1928+ The "user" entry has a number of methods available for information:
1929+
1930+ =============== =========================================================
1931+ Method Description
1932+ =============== =========================================================
1933+ first True if the current item is the first in the sequence.
1934+ last True if the current item is the last in the sequence.
1935+ even True if the current item is an even item in the sequence.
1936+ odd True if the current item is an odd item in the sequence.
1937+ number Current position in the sequence, starting from 1.
1938+ letter Current position in the sequence as a letter, a through
1939+ z, then aa through zz, and so on.
1940+ Letter Same as letter(), except uppercase.
1941+ roman Current position in the sequence as lowercase roman
1942+ numerals.
1943+ Roman Same as roman(), except uppercase.
1944+ =============== =========================================================
1945+
19151946
19161947The utils variable
19171948~~~~~~~~~~~~~~~~~~
0 commit comments