[ZPT] repeating a table cell conditionally
Clint Brubakken
cabrubak@inetic.com
27 Aug 2001 15:17:53 -0500
I'm pretty new to page templates, and have been reading all I could find
on it, and bugging philh on #zope on open projects, and I have a
question on how to do something:
I have a table and a row, and I want to repeat cells over a sequence
and if the current item in the sequence it a vaild object print its id
in a <th></th>, if not do nothing.
Here is what I had, but it adds an empty <th></th> pair :
<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>
the best solution I found was :
<tr><th tal:repeat="year python:range(1989, 2001)"
tal:replace="python:test(exists(path(string('here/$year'))),
'<th>%s</th>'% path(string('here/$year')).title_or_id(),
'')">Year</th></tr>
which actually doesn't work.
Essentially I need define and condition to have a lower precedence then
repeat in the tag. The solution in the TAL spceification of surrounding
it with another tag can't work as no tag can come between <tr> and <th>
--
Clint Brubakken <cabrubak@inetic.com>
Programmer Analyst
Inetic Web Development
---
Black holes are where God divided by zero.