Question about "tal:condition"
Hi, I have a question about the usage of the tal:condition statement. In the code I have included I generate a table with two types of rows that have a different value for the class attribute (located in the <td> tag). It seems to me that this code can be much shorter by using only one <td> block. How can I accomplish this? Thanks in advance!! Arjan Huijzer ------------------------------------ <table> <tbody> <tr tal:repeat="link container/objectValues"> <td tal:condition="repeat/link/odd" class="lb"> <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> <td tal:condition="repeat/link/even" <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> </tr> </tbody> </table> __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com
Arjan Huijzer wrote:
In the code I have included I generate a table with two types of rows that have a different value for the class attribute
<table> <tbody> <tr tal:repeat="link container/objectValues"> <td tal:condition="repeat/link/odd" class="lb"> <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> <td tal:condition="repeat/link/even" <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> </tr> </tbody> </table>
This would do: <table> <tbody> <tr tal:repeat="link container/objectValues"> <td tal:define="odd repeat/link/odd" tal:attributes="class python:test(odd, 'lb', nothing)"> <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> </tr> </tbody> </table> Cheers, Evan @ 4-am
How about <td tal:attributes="class python:[condition] and 'class1' or 'class2'"> Arjan Huijzer wrote:
Hi,
I have a question about the usage of the tal:condition statement. In the code I have included I generate a table with two types of rows that have a different value for the class attribute (located in the <td> tag). It seems to me that this code can be much shorter by using only one <td> block. How can I accomplish this?
Thanks in advance!! Arjan Huijzer
------------------------------------
<table> <tbody> <tr tal:repeat="link container/objectValues"> <td tal:condition="repeat/link/odd" class="lb"> <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> <td tal:condition="repeat/link/even" <a tal:content="link/title" tal:attributes="href link/url" href="link.html" target="_new">Link Title</a> </td> </tr> </tbody> </table>
__________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Arjan Huijzer -
Chris Beaven -
Evan Simpson