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

Fergal Daly fdaly at sift.co.uk
Thu Jul 31 18:44:56 EDT 2003


On Thursday 31 July 2003 17:06, Charlie Clark wrote:
> XML isn't supposed to be fast to execute, just relatively simple to
> maintain.

Speed doesn't really come into it but easy to maintain is very important.

> I find that anything that goes beyond a tal:condition or python: test() is
> probably over-complex for ZPT and usually time for a PythonScript or an
> external method and I really like being encouraged down that path.

I agree, I like the fact that TAL forces you to use it as a template language. 
Anyone who tries to use TAL as a general programming language is in for pain 
and rightly so. However if-else is fairly fundamental, the last time I used a 
language without an else was assembler and Commodore 64 BASIC. It's also 
available in probably every other template system out there.

I can see how PythonScript or a method will solve the problem but then you 
lose all the advantages of using TAL. Take the hypothetical example

<tag tal:if="user/isLoggedIn">
	welcome back <tag tal:replace="user/name"/>
</tag>
<tag tal:else>
	please log in
</tag>

Doing this with a method would look like

<tag tal:replace="structure user/welcomemessage"/>

But now a big chunk of our template is hidden away in a method call, which 
means the programmer has more code to maintain and the designer has a part of 
his template that doesn't show up in his editor. TAL is the best language 
I've seen for avoiding this sort of thing, it shouldn't be necessary to 
introduce it just to do an "else".

I don't think you can argue that adding "else" to TAL is expanding the 
language beyond what it should be and at a guess, I'd say that most people on 
this list have templates where they have worked around the lack of an else.

I'm trying to push TAL (well actually Petal - the Perl port) in my new job. 
They are using their own home-grown template language which is nowhere near 
as good as TAL not having an else makes it quite a bit more difficult to 
sell,

F





More information about the ZPT mailing list