[ZPT] repeating a table cell conditionally

Evan Simpson evan@zope.com
Mon, 27 Aug 2001 21:37:11 -0400


From: "Clint Brubakken" <cabrubak@inetic.com>
> <tr><th tal:repeat="year python:range(1989, 2002)">
> <span tal:define="volume python:path('here/%s' % year) or nothing"
>        tal:condition="volume"
> tal:replace="volume/id">Year</span></th></tr>

You could write an ugly filter/map/lambda, or put the logic in a Script,
but unless you're using a tool that complains bitterly about it, I would
go ahead and use:

<tr><tal:block repeat="year python:range(1989, 2002)">
<th tal:define="volume python:path('here/%s' % year) or nothing"
tal:condition="volume"
tal:content="volume/id">Year</th></tal:block></tr>

Cheers,

Evan @ Zope