[Zope] inelegant repetition of ZPT code

Allen aschmidt at fredericksburg.com
Tue Nov 25 19:45:02 EST 2003


I don't get it! This answer posted earlier works great.... and my nickname is DTML-man!

<tr tal:attributes="bgcolor python: test(repeat['item'].odd, 'white', 'lightgray')" /> 

-Allen


Wilson, Derek wrote:

> try this...
> 
> <table tal:repeat="item here/listItems">
> 
>    <tr bgcolor="white" tal:omit-tag="not:repeat/item/even">
>    <tr bgcolor="lightgray" tal:omit-tag="not:repeat/item/odd">
> 
>                     <td>...</td>
> 
>    </tr>
>    </tr>
> 
> </table>
> -----Original Message-----
> From:	Phil Harris [mailto:phil at harris-family.info]
> Sent:	Tue 11/25/2003 4:23 PM
> To:	Zope list
> Cc:	
> Subject:	Re: [Zope] inelegant repetition of ZPT code
> 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 at 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 at 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 at 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> 
> 




More information about the Zope mailing list