[Zope-dev] Re: ZPT and else

Florent Guillaume fg@nuxeo.com
Sat, 11 May 2002 14:53:41 +0000 (UTC)


Brent Hendricks  <brentmh@ece.rice.edu> 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:
> 
>    <div id="edit-area"
>         tal:define="editItems python:here.getMenuItem(...)">
> 
>     <h3>Edit Menu Items</h3>
>     <form action="Delete" method="post" name="actForm"
>           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) ...
> 
>     </form>
>    </div>
> 
> 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:fg@nuxeo.com