[Zope] Newbie: TAL Conditions
Florent Guillaume
fg at nuxeo.com
Tue Dec 7 09:50:12 EST 2004
> This works fine. However, where there isn't a record (i.e. an empty
> string), a <TD> will not be defined so that it leaves ugly gaps in the
> table. To ensure that a '<TD> </TD>' replaces an empty string '' I
> added two tal:condition statements. This works, but is sort of ugly
> looking as, in my head, it is the equivalent of two 'if' statements when
> it should be an 'if/else'. The below code works, however is there a
> cleaner way to do this?
>
> ### START CODE ###
>
> <table border="1">
> <tr><th>Date</th><th>Server</th></tr>
> <tr tal:repeat="transfer container/getTransfers">
> <td tal:content="structure transfer/time_stamp">time_stamp</td>
> <td tal:condition="python: transfer.server==''"> </td>
> <td tal:condition="python: transfer.server!=''"
> tal:content="structure transfer/server">server</td>
> </tr>
> </table>
You can just do:
<td tal:content="structure python:transfer.server or ' '">server</td>
Florent
--
Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D
+33 1 40 33 71 59 http://nuxeo.com fg at nuxeo.com
More information about the Zope
mailing list