[ZPT] Add 'parity' to repeat?

Evan Simpson evan at 4-am.com
Mon Aug 25 14:52:47 EDT 2003


The use of "python:test(path('repeat/thing/odd'), 'odd', 'even')" and 
variants has become so common as to merit its own method.

I suggest that 'parity()' be added to the stock repeat object.  It would 
return the string "odd" or "even", depending on the repetition index.

This would allow the nicely concise:

   <tr tal:attributes="class repeat/row/parity">

An alternate approach would be to create a subpath prefix that has a 
'parity' method, perhaps along with all of the other repetition methods 
that are computed directly from 'index', such as 'roman' and 'odd'. 
Then we could write "repeat/row/index/int:parity", for example.  Of 
course, this depends on the inclusion of subpath prefixes into a release.

Thoughts?

evan @ 4-am




More information about the ZPT mailing list