Edgewall Software

Changes between Version 1 and Version 2 of GenshiRecipes/AlternatingTableRows

Show
Ignore:
Timestamp:
03/02/08 07:49:37 (6 years ago)
Author:
athomas
Comment:

Added `cycle recipe

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/AlternatingTableRows

    v1 v2  
    1010 
    1111This will produce a table row in the html output with the ''class="odd"'' or ''class="even"'' alternating on each row.  
     12 
     13== Using `itertools.cycle` == 
     14 
     15Pass `itertools.cycle` to your template and: 
     16 
     17{{{ 
     18#!genshi 
     19<table py:with="cls=cycle(('first', 'second', 'third'))"> 
     20  <tr py:for="firstname, lastname in nameslist" class="${cls.next()}"> 
     21... 
     22}}} 
     23 
     24This will produce table rows cycling through `class="first"`, `class="second"` and `class="third"`.