[Zope] Howto test if macro evaluates to nothing

Dieter Maurer dieter at handshake.de
Wed Mar 10 15:54:07 EST 2004


Florian Schulze wrote at 2004-3-9 11:44 +0100:
>I would like to know wether there is a way to test if a macro evaluates to 
>nothing.
>
>I tried the following:
><div tal:condition="here/my_macros/macros/macro_name"
>      metal:use-macro="here/my_macros/macros/macro_name">
></div>
>
>But the macro returns a tree of lists and tuples.

Sure, this is the macro code. It is unlikely to be empty...

When you want to check, whether the result of macro rendering
is empty, then you must render the macro and look at the result.
In the trivial case (the macro is independent of arguments defined
in the caller),
you can wrap your macro use in a PageTemplate, call this template
and check its result. When your macro needs arguments, you
must pass them to the template.

-- 
Dieter



More information about the Zope mailing list