tal:repeat

This attribute handles iterable objects like arrays, associative arrays, and objects implementing the PHP5 Iterator class.

The repeat attribute repeats its element and its content until the end of the specified resource.

<tr tal:repeat="item some/result">
  <td tal:content="item">text replaced by item</td>
</tr>

Within a loop, you can access the current loop information (and that of its parent for nested loops) using specific repeat/* paths.

In the above example:

"item" depends on the receiver variable defined in tal:repeat expression.

The most common usage of tal:repeat is in using some SQL database result. The following code will work if playersRanking contains object that implements PHP's Iterator interface:

<table>
  <thead>
    <tr>
      <th>Position</th>
      <th>Player</th>
      <th>Score</th>
    </tr>
  </thead>
  <tbody>
    <tr tal:repeat="ranking playersRanking">
      <td tal:content="ranking/position"/>
      <td tal:content="ranking/player"/>
      <td tal:content="ranking/score"/>
    </tr>
  </tbody>
</table>