[Zope-dev] ZPT and 'else'

Tim Hoffman timhoffman@cams.wa.gov.au
10 May 2002 11:58:21 +0800


The big problem with the whole 'else' issue as I see
it, is that non coders, using dreamweaver etc.. would no doubt end
up with both bit's of html in their template.

T
 On Fri, 2002-05-10 at 11:39, Marc Lindahl wrote:
> Yecch!
> 
> Why not:
> <if ...>
> True stuff
> </if>
> <else>
> False stuff
> </else>
> 
> If leaves around boolean result, else picks up the most recent one... It's
> like they push on a stack so you can nest them.... Something like that?
> 
> 
> on 5/9/02 11:10 PM, Jeffrey P Shell at jeffrey@cuemedia.com scrivened:
> 
> > 'else' is tricky within the block oriented structure of anything XML-ish,
> > because of the concept of 'well-formedness'.  The 'if' statement would have
> > to be singly wrapped, and the else block wrapped separately, looking at
> > least somewhat awkward any way you go about it.  The best I can come up with
> > in my mind is this, in order to have the 'else' pick up on the condition
> > expressed in its surrounding container.  But, yuck:
> > 
> > <if ...>
> > true stuff
> > <else>
> > false stuff
> > </else>
> > </if>
> > 
> > 
> > A good page template way is something like this:
> > 
> > <tal:if condition="myTalesExpression">
> > truth
> > </tal:if>
> > <tal:else condition="not:myTalesExpression">
> > false
> > </tal:else>
> > 
> > The 'not' TALES namespace is valuable.  The downside is that you evaluate
> > the expression twice.  A good way to work within this is something that I
> > did earlier today, outside of this conversation, where I evaluate an
> > expression earlier and assign it to a variable:
> > 
> > <div id="edit-area"
> >    tal:define="editItems python:here.getMenuItem(...)">
> > 
> > <h3>Edit Menu Items</h3>
> > <form action="Delete" method="post" name="actForm"
> >       tal:condition="editItems">
> > 
> >    ... (form and table elements, and a loop over editItems
> >         contained in here if there were results) ...
> > 
> > </form>
> > 
> > <div class="emph"
> >      tal:condition="not:editItems">
> >  No menu items available
> > </div>
> > 
> > </div>
> > 
> > 
> > This is something I did a lot in DTML too, setting a search result to either
> > a global variable, or inside of a large <dtml-let> namescape
> 
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )