[ZPT] Re: TAL's lack of an else...
Fergal Daly
fergal at esatclear.ie
Fri Aug 1 16:48:22 EDT 2003
On Friday 01 August 2003 14:30, Jean-Michel Hiver wrote:
> http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html
>
> One of them is HTML_Tree, which parses HTML into a DOM, and then
> programmatically modifies the contents of nodes.
>
> As you can see it's got no 'else'. Phear. I've won a pint. Yey!
> I'll get the salt and vinegar crisps :)
My attempts to find it on CPAN or off CPAN have been unsuccessful but I did
find HTML::Seamstress which also has no else, as to how respectable it is...
Anyway, I was fairly sure I was going to lose that bet so I'll pay up when you
present Petal at London.pm - where I'm sure you'll need it after all the
questions about why is there no "else"!
> To go back to your problem how about having something like (throwing
> ideas in):
>
> <tag tal:condition="true:foo" id="foo_condition">
> <!--
> automagically set a global variable
> called #foo_condition to TRUE
> -->
> ...
> </tag>
> <tag tal:condition="false: #foo_condition">
> ...
> </tag>
>
> Am I making any sense?
That seem's similar to the condition-groups but uses a different syntax. The
problem is that the tags are not bound tightly together as a group, that's
kind of why I prefer something this shape
<outer-tag tal:if-group>
<tag tal:if="expr">
something
</tag>
<tag tal:elsif="another-expr">
something 2
</tag>
<tag tal:else>
somethign else
</tag>
</outer-tag>
and you make it illegal to put anything in the <outer-tag> tag that isn't a
tal:if, tal:elsif or tal:else expression. As soon as one of the condtions is
found to be true, processing leaves the <outer-tag> scope. Keeping it all
inside a scope makes it easier to parse too because you don't have to look at
ids and think about which set of conditions is this current one related to,
F
More information about the ZPT
mailing list