Documentation Suggestion
Jonathan Vanasco <[email protected]> Fri, 3 Feb 2006 15:59:49 -0500
| Newsgroups | gmane.comp.lang.perl.modules.petal |
|---|---|
| Message-ID | <[email protected]> |
RE: Petal/Cookbook Generating even/odd rows (submitted by Warren Smith) First- The decode modifier is GREAT. Unfortunately though, I can't use it as I use Petal to share templates between different languages. For those that need to do the same , there is a way to assign attributes based on repeat characteristics in pure TAL === <div tal:repeat="row rows"> <tag tal:omit-tag="string:1" tal:condition="repeat/even"><tag tal:define="rowClass string:rowEven" tal:omit-tag="string:1"/></tag> <tag tal:omit-tag="string:1" tal:condition="repeat/odd"><tag tal:define="rowClass string:rowOdd" tal:omit-tag="string:1"/></tag> <div tal:attributes="class rowClass" > This will use either the rowEven or rowOdd class. All of the 'tag' elements are omitted on render. This uses a nested define tag in a condition tag, because define precedes condition in order of operations. </div> <div> === The above is ugly and inefficient. , but if decode: is not an option, it saves time spend making&updating duplicate conditional rows (one for even, one for odd) , which can be a hassle to maintain when designing things.