[ZPT] Mini proposal: repeat-define and repeat-condition

Evan Simpson evan@4-am.com
Fri, 24 Jan 2003 17:05:51 -0600


Dieter Maurer wrote:
> Casey Duncan wrote at 2003-1-23 10:24 -0500:
>  > Invent a new repeat tag that happens first and leave the existing repeat 
>  > tag alone.
> I like this proposal.
> 
> One minor problem: how do old and new repeat tag interact with one another.
> Probably, we can forbid that both occur on the same tag.

Hmm.  I'm beginning to like the original proposal better.  After all, 
while we would probably want to forbid the combination of old and new 
repeat statements on a tag, any combination of define, condition, 
repeat-define, and repeat-condition is sensible.

Not only that, all five statements are quite likely to be useful on a 
single tag:

<tr tal:define="items here/getItems"
     tal:condition="options/itemize"
     tal:repeat="item items"
     tal:repeat-define="name item/name;price item/price"
     tal:repeat-condition="python:name and price">

How about calling them "define2" and "condition2" instead, and allowing 
them even in the absence of a tal:repeat?  It's a little ugly, and could 
be taken to imply the existence of "condition3", etc., but would allow:

<div tal:define="x here/getX"
      tal:condition="python:len(x) == 2"
      tal:define2="x0 python:x[0];x1 python:x[1]"
      tal:condition2="python:x0 < x1">

The fact that they sandwich tal:repeat in the order of operations is 
sufficient rationale (for me) for having two sets without 
over-generalizing into "defineN" and "conditionN".

Cheers,

Evan @ 4-am