It is also possible to repeat a block n times, for that purpose we have the stl:repeat attribute:
<div stl:repeat="task tasks">
<h4>${task/title}</h4>
<p>${task/description}</p>
</div>
This is the syntax of the stl:repeat attribute:
stl:repeat="name expression"
The expression is a normal expression, as we have seen in Section 9.2.1. The only difference is that the value we get at the end must be a sequence.
For every item in the sequence, STL will process the XML element, with the name variable associated to the value of the item. For instance, with the namespace:
namespace['tasks'] = [
{'title': 'Finish the Documentation',
'description': 'Documentation is very important'},
{'title': 'Release 1.0',
'description': 'And rejoice'},
]
We would get the output:
<div>
<h4>Finish the Documentation</h4>
<p>Documentation is very important</p>
</div>
<div>
<h4>Release 1.0</h4>
<p>And rejoice</p>
</div>