[ZPT] Re: Zope-Dev digest, Vol 1 #1682 - 11 msgs

Godefroid Chapelle gotcha@swing.be
Fri, 10 May 2002 10:36:00 +0200


At 06:13 10/05/2002, zope-dev-request@zope.org wrote:
>'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


It is maybe not clear that the above is really usable and allowed. I do not 
know how and where to stress that the tal: marked tags are underdocumented 
what a pity.

I have already tried : 
http://www.zope.org/Documentation/ZopeBook/AdvZPT.stx#3-44

Sorry that I am not able to explain it better...
--

Godefroid Chapelle

BubbleNet sprl
rue Victor Horta, 18 / 202
1348 Louvain-la-Neuve
Belgium

Tel + 32 (10) 459901
Mob + 32 (477) 363942

TVA 467 093 008
RC Niv 49849