[ZPT] Re: TAL's lack of an else...

Tino Wildenhain tino at wildenhain.de
Fri Aug 1 16:24:42 EDT 2003


Fergal Daly wrote:

> Yep, but that's programming in XML for you. Anyway, the alternative if even 
> worse
> 
> <tal:x tal:define="temp_cond_var user/isLoggedIn">
>   <tal:x tal:condition="temp_cond_var">
>     welcome
>   </tal:x>
>   <tal:x tal:condition="not:temp_cond_var">
>     please login
>   </tal:x>
> </tal:x>
> 
> and that's without even trying to do an "elsif" and you better make sure that 
> "temp_cond_var" doesn't clash with any variables inside your conditions.
> 
> 
>>I like TAL because it's got very few instructions with which you can do
>>a lot. If the syntax starts to have condition-group, repeat-define and
>>others, then it'll quickly become some horrible attribute-soup.
> 
> 
> Absolutely but I think that not having "else" is a serious deficiency. If you 
> can point me to another vaguely respectable template language that doesn't 
> have "else" I'll buy you a pint!

where does the temp_cond come from? why not using user/isLoggedIn
everywhere instead?

After all, complete different layout with tal: was not the goal for this
particular template language.
In opposition to all that other languages which indeed need a lot of
ability because they represent actual code, tal should only provide
a lean shell for output.
If you have two different states: logged in and not logged in - why
not using different templates? Via metal: you would derive from
a common design and only change whats specific for the actual state.
This is what keeps templates clean.

Simple rule of thumb: (1) when it becomes complicated to do with TAL, 
you pobably do something the wrong way. Redesign your application in
this case.
(2) If your html-view of the template (without rendering) looks ugly,
proceed as in (1)

HTH
Tino Wildenhain




More information about the ZPT mailing list