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

Casey Duncan casey@zope.com
Thu, 23 Jan 2003 10:24:07 -0500


On Tuesday 21 January 2003 09:16 pm, Shane Hathaway wrote:
> Evan Simpson wrote:
>=20
> >  > > I had propsed changing the order of operations from "define,=20
> > condition,
> >  > > repeat, etc." to "repeat, define, condition, etc.", and using a
> >  > > processing instruction in a similar fashion to Python's "import =
from
> >  > > __future__".
>=20
> +1 from me.  It's better than my proposal.

Here's a counter-proposal that I think might combine both of yours and so=
lve=20
the backward compatibility issue:

Invent a new repeat tag that happens first and leave the existing repeat =
tag=20
alone.

This tag would not be understood by older TAL processors, but it would no=
t=20
break any existing page templates or harm those blissfully ignorant of th=
e=20
change.

Something like:

<div tal:pre-repeat=3D"item here/foo" tal:define=3D"ob item/getObject">

Another similar but more general idea would be to invent some way to spec=
ify=20
in a tag that you wanted it to happen before other TAL tags. A stupid way=
=20
that comes to mind would be to invent a new namespace. Another would be t=
o=20
introduce a flag in the attribute value that says "do me first". I'm not =
sure=20
how we would spell this though.

For example:

<div pretal:repeat=3D"item here/foo" tal:define=3D"ob item/getObject">

All "pretal" tags get evaluated before "tal" tags (but using the same ord=
er=20
within that namespace as within tal).

-Casey