[ZPT] Conditional attributes in TAL?

Jan Van Uytven wyvern at uvic.ca
Mon Mar 1 19:38:32 EST 2004


Hi all,

This is my first posting to this list, so forgive me if for my newbie
questions.

I have a ZSQL method that returns data for a TAL repeat tag. Now I want
to present the returned info in a table. I also want to apply a
different CSS style to a row depending on whether it's an even or odd
row. Sounds simple enough, but to my dismay there doesn't seem to be a
TAL method for adding an attribute to a tag depending on a given
condition. My hack is to do something like:

<div tal:repeat="pc here/zsql/getPCsZSQL">
<tr tal:condition="repeat/pc/odd" class="oddrow">
<td><strong><span tal:replace="pc/name"/></strong></td>
<td><span tal:condition="pc/dead">Yes</span></td>
<td><span tal:condition="pc/retired">Yes</span></td>
</tr>
<tr tal:condition="repeat/pc/even" class="evenrow">
<td><strong><span tal:replace="pc/name"/></strong></td>
<td><span tal:condition="pc/dead">Yes</span></td>
<td><span tal:condition="pc/retired">Yes</span></td>
</tr>
</div>

This is ugly, forcing me to repeat every cell in the table twice for a
given row. Is there a cleaner/simpler way of doing it? Am I missing
something obvious?

Thanks,

Jan

---
Jan (Wyvern) Van Uytven
Sysadmin, UVic TRIUMF
wyvern at uvic.ca

Randomly selected from my quote-file:

'A world rests on four pillars:
The learning of the wise, the justice of the great,
the prayers of the righteous, and the valor of the brave.'
	-Frank Herbert




More information about the ZPT mailing list