[ZPT] Mini proposal: repeat-define and repeat-condition
Dieter Maurer
dieter@handshake.de
Sun, 26 Jan 2003 18:46:18 +0100
Evan Simpson wrote at 2003-1-24 17:05 -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.
I think, we can forget about the "condition" altogether:
Python provides list comprehension in a very intuitive way.
Therefore, we do not need "repeat-condition".
If you already have one way to do it, think at least thrice
before you invent another one.
> 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".
One of the original aims for TAL has been: KISS, keep it as simple
as possible. This was a good aim.
Dieter