[Petal] Documentation Suggestion
Jonathan Vanasco
jon at 2xlp.com
Fri Feb 3 20:59:49 GMT 2006
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.
More information about the Petal
mailing list