Re: [Zope-dev] Re: ZPT and else

2002-05-11 Thread Florent Guillaume

Brent Hendricks  <[EMAIL PROTECTED]> wrote:
> Another way to do this is to use the python test() function inside
> tal:replace to conditionally replace the "if" content with the "else"
> content.  For example:
> 
> tal:define="editItems python:here.getMenuItem(...)">
> 
> Edit Menu Items
>tal:replace="python:test(editItems, default, 'No menu items
> available')">
> 
>... (form and table elements, and a loop over editItems
> contained in here if there were results) ...
> 
> 
>
> 
> This technique works well when you have one case which is more
> "involved" and can be the default, and another case which is simple text
> (like an error message).

This is very ugly, even if probably tempting for a PHP programmer :)
Also if i18n comes into play, you'll have to use two different ways to
internatonalize things...

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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 )



[Zope-dev] Re: ZPT and else

2002-05-10 Thread Brent Hendricks

Quoting "Jeffrey P Shell":
  > 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:
  >
  >   tal:define="editItems python:here.getMenuItem(...)">
  >
  >  Edit Menu Items
  >  tal:condition="editItems">
  >
  > ... (form and table elements, and a loop over editItems
  >  contained in here if there were results) ...
  >
  >  
  >
  > tal:condition="not:editItems">
  >   No menu items available
  >  
  >
  > 

Another way to do this is to use the python test() function inside
tal:replace to conditionally replace the "if" content with the "else"
content.  For example:

   

Edit Menu Items


   ... (form and table elements, and a loop over editItems
contained in here if there were results) ...


   

This technique works well when you have one case which is more
"involved" and can be the default, and another case which is simple text
(like an error message).


-- Brent

-

"The programmer, like the poet, works only slightly removed from pure
   thought-stuff.  He builds his castles in the air, from air, creating
   by exertion of the imagination.  Few media of creation are so
   flexible, so easy to polish and rework, so readily capable of
   realizing grand conceptual structures."
  -- Frederick Brooks, Jr., The Mythical Man Month




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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 )