On 11/1/06, Richard (koorb) <[EMAIL PROTECTED]> wrote:
>
> I tried
>
> <tr py:for="item in item_list"
> class="${tg.cycle(('odd','even')).value}">
> <td>${item.name}</td>
> </tr>
>
> I also tried ${tg.cycle(('odd','even'))} (without .value) But I only
> get "None" or "odd" ?
Personally, I think tg.cycle is broken: it claims to be a wrapper for
itertools.cycle, but it's far more limited than itertools' version:
for example, it's not even iterable itself!
I think it's way easier just to use the "real" cycle and be done with it:
<?python from itertools import cycle ?>
<tr py:for="item,cls in zip(item_list, cycle(['odd','even']))" class="${cls)">
<td py:content="item.name"/>
</tr>
Alternately, you use the enumerate/list hack from the DataGrid template:
<tr py:for="idx, item in enumerate(item_list)" class="${['odd',
'even'][idx%2]}">
<td py:content="item.name"/>
</tr>
--
Tim Lesher <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---