[Zope] <dtml-elif> problem

Thomas B. Passin tpassin@mitretek.org
Fri, 2 Aug 2002 13:03:36 -0400


You have an opening dtml-let tag in one element and the closing one for it
in another element.  The dtml expresssion is not well-formed.  The parser
expects to have your <dtml-let dir="do_"> and similar elements to nest
properly.  That is why you get the error.

DTML does not work by building a string using the conditionals and then
evaluating that string (in which case your approach nmight work).  It
effectively builds a tree, and you cannot have part of a branch, only whole
branches or none.

You need to nest your expressions completely  You can have something like
this:

<dtml-if "filename[3:6]=='do_'">
    <dtml-let dir="do_">
       <!--do something with "do_"-->
   </dtml-let>
<dtml-elif "filename[3:6]=='aa'">
   <dtml-let dir="aa_">
      .....
   </dtml-let>
<dtml-else>
   .....
</dtml-if>

Cheers,

Tom P

[Tom Germaine]
>
> <dtml-if expr="filename[3:6]=='do_'"><dtml-let dir="do_">
> <dtml-elif expr="filename[3:6]=='aa_'"><dtml-let dir="aa_">
> <dtml-else><dtml-let dir="vth">
>
> <dtml-with avc>
> <dtml-call
>   expr="dir.manage_addDTMLDocument(filename,mytitle)">
> </dtml-with>
>
> </dtml-let>
> </dtml-if>
>
> </dtml-let>
> </dtml-let>
>
> <dtml-var showFiles>
> <dtml-var standard_html_footer>
> -------
> with error message:
> Unexpected tag, for tag <dtml-elif expr="filename[3:6]=='aa_'">
>
> However, the code function ok if dtml-elif and dtml-else lines are
> omitted.
>
> I cannot understand why and would appreciate any solutions.
>