[Zope] inelegant repetition of ZPT code

Paul Winkler pw_lists at slinkp.com
Tue Nov 25 16:13:37 EST 2003


On Tue, Nov 25, 2003 at 09:52:51PM +0100, Andre Meyer wrote:
> 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.

Maybe not the most elegant, but it avoids the repetition:

<table>
  <span tal:repeat="item here/listItems">
    <tr bgcolor="lightgray" 
       tal:attributes="bgcolor python:path('repeat/item/odd') and 'white' or default">
      <td>...</td>
    </tr>
  </span>
</table>


-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's GANGSTA MERRY MAN!
(random hero from isometric.spaceninja.com)



More information about the Zope mailing list