[Zope] Newbie: TAL Conditions
Andrew Milton
akm at theinternet.com.au
Tue Dec 7 09:32:44 EST 2004
+-------[ Tom_Rectenwald at carmax.com ]----------------------
|
| Hello all,
[snip]
| 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?
Probably millions of ways... here's one.
|
| ### 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>
Replace this;
| <td tal:condition="python: transfer.server==''"> </td>
| <td tal:condition="python: transfer.server!=''"
| tal:content="structure transfer/server">server</td>
With this;
<tal:block define="theContent python:test(transfer.server, transfer.server,' '">
<td tal:content="structure theContent"></td>
</tal:block>
| </tr>
| </table>
|
| ### END CODE ###
--
Andrew Milton
akm at theinternet.com.au
More information about the Zope
mailing list