[Zope] Re: Question about "tal:condition"

Evan Simpson evan@4-am.com
Thu, 13 Feb 2003 14:45:49 -0600


Arjan Huijzer wrote:
> In the code I have included I generate a
> table with two types of rows that have a different
> value for the class attribute
> 
> <table>
>   <tbody>
>     <tr tal:repeat="link container/objectValues">
>         <td tal:condition="repeat/link/odd"
>             class="lb">
>           <a tal:content="link/title"
>              tal:attributes="href link/url"
>              href="link.html" 
>              target="_new">Link Title</a>
>         </td>
>         <td tal:condition="repeat/link/even"
>           <a tal:content="link/title"
>              tal:attributes="href link/url"
>              href="link.html" 
>              target="_new">Link Title</a>
>         </td>
>     </tr>
>   </tbody>
> </table>

This would do:

<table>
   <tbody>
     <tr tal:repeat="link container/objectValues">
         <td tal:define="odd repeat/link/odd"
             tal:attributes="class python:test(odd, 'lb', nothing)">
           <a tal:content="link/title"
              tal:attributes="href link/url"
              href="link.html"
              target="_new">Link Title</a>
         </td>
     </tr>
   </tbody>
</table>

Cheers,

Evan @ 4-am