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

Markus Kemmerling markus.kemmerling at mediaweb.at
Fri Aug 1 17:21:55 EDT 2003


At 15:15 01.08.2003 +0200, Jean Jordaan wrote:
>>Yep, but that's programming in XML for you.
>
>How about we leave that to the unlucky souls who need to write XSLT.

There's no else in XSLT ;-) But there is a choose/when/otherwise.
I would appreciate to have a similar construct in TAL, but I don't know how 
to do it in a simple way, although you could write:

<ul tal:choose="flavour" tal:repeat="variety icecreams">
    <li tal:when="flavour python:variety in ('Cherry', 'Strawberry')">
I like <span tal:replace="variety">this flavor</span> very much.
    </li>
    <li tal:when="flavour python:variety in ('Vanilla', 'Chocolate')">
I like <span tal:replace="variety">this flavor</span>.
    </li>
    <li tal:when="flavour python:variety in ('Coffee', 'Mint Chip')">
I don't like <span tal:replace="variety">this flavor</span>.
    </li>
    <li tal:otherwise="flavour">
I haven't tried <span tal:replace="variety">this flavor</span>.
    </li>
</ul>

At 13:55 01.08.2003 +0100, Fergal Daly wrote:
><tal:x tal:if-else>
>   <tal:x tal:if="user/isLoggedIn">
>     welcome
>   </tal:x>
>   <tal:x tal:else>
>     please login
>   </tal:x>
></tal:x>

That won't work: In a wellformed document every attribute must have a value.

Markus Kemmerling






More information about the ZPT mailing list