RE: [Zope] inelegant repetition of ZPT code
How about: <table> <span tal:repeat="item here/listItems"> <span tal:condition="repeat/item/even"><tr bgcolor="white"></span> <span tal:condition="repeat/item/odd"><tr bgcolor="lightgray"></span> <td>...</td> </tr> </span> </table> I haven't tested it, but it should work. -----Original Message----- From: Andre Meyer [mailto:a.meyer@hccnet.nl] Sent: Tue 11/25/2003 1:52 PM To: Zope Mailing List Cc: Subject: [Zope] inelegant repetition of ZPT code Hi Zopers Another detail that bugs me: how can I translate the following dtml code to zpt. It colours table rows in grey/white alternatively. Is the zpt version below the only way? It is clearly very inelegant to repeat code. DTML ... <table> <dtml-in listItems> <tr <dtml-if sequence-even>bgcolor="lightgray"</dtml-if>> <td>...</td> </tr> </dtml-in> </table> ZPT ... <table> <span tal:repeat="item here/listItems"> <tr bgcolor="white" tal:condition="repeat/item/even"> <td>...</td> </tr> <tr bgcolor="lightgray" tal:condition="repeat/item/odd"> <td>...</td> </tr> </span> </table> thanks and best wishes Andre _______________________________________________ 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 )
That won't work because you have badly formed html in there. The <tr>s are badly nested with the spans, you must have correctly formed html when using TAL. Phil On Tue, 25 Nov 2003 16:15:05 -0700 "Wilson, Derek" <dwilson@abrazohealth.com> wrote: dwilson> How about: dwilson> dwilson> <table> dwilson> <span tal:repeat="item here/listItems"> dwilson> <span tal:condition="repeat/item/even"><tr bgcolor="white"></span> dwilson> <span tal:condition="repeat/item/odd"><tr bgcolor="lightgray"></span> dwilson> <td>...</td> dwilson> </tr> dwilson> </span> dwilson> </table> dwilson> dwilson> I haven't tested it, but it should work. dwilson> dwilson> -----Original Message----- dwilson> From: Andre Meyer [mailto:a.meyer@hccnet.nl] dwilson> Sent: Tue 11/25/2003 1:52 PM dwilson> To: Zope Mailing List dwilson> Cc: dwilson> Subject: [Zope] inelegant repetition of ZPT code dwilson> dwilson> dwilson> dwilson> Hi Zopers dwilson> dwilson> Another detail that bugs me: how can I translate the following dtml code dwilson> to zpt. It colours table rows in grey/white alternatively. Is the zpt dwilson> version below the only way? It is clearly very inelegant to repeat code. dwilson> dwilson> dwilson> DTML dwilson> dwilson> ... dwilson> <table> dwilson> <dtml-in listItems> dwilson> <tr <dtml-if sequence-even>bgcolor="lightgray"</dtml-if>> dwilson> <td>...</td> dwilson> </tr> dwilson> </dtml-in> dwilson> </table> dwilson> dwilson> dwilson> ZPT dwilson> dwilson> ... dwilson> <table> dwilson> <span tal:repeat="item here/listItems"> dwilson> <tr bgcolor="white" tal:condition="repeat/item/even"> dwilson> <td>...</td> dwilson> </tr> dwilson> <tr bgcolor="lightgray" tal:condition="repeat/item/odd"> dwilson> <td>...</td> dwilson> </tr> dwilson> </span> dwilson> </table> dwilson> dwilson> dwilson> thanks and best wishes dwilson> Andre dwilson> dwilson> dwilson> dwilson> _______________________________________________ dwilson> Zope maillist - Zope@zope.org dwilson> http://mail.zope.org/mailman/listinfo/zope dwilson> ** No cross posts or HTML encoding! ** dwilson> (Related lists - dwilson> http://mail.zope.org/mailman/listinfo/zope-announce dwilson> http://mail.zope.org/mailman/listinfo/zope-dev ) dwilson> dwilson> -- Phil Harris <phil@harris-family.info>
participants (2)
-
Phil Harris -
Wilson, Derek