[ZPT] Using define-macro and use-macro together

Fernando Martins fmartins@hetnet.nl
Sat, 28 Dec 2002 16:48:27 +0100


Troy wrote:
> There was a thread here about 1 week ago called "tal:define and
> metal:use-macro."  Dieter answered your question there:
>
> Quoth Dieter:
>> Because the macro replaces the complete tag containing the
>> "metal:use-macro".
>
> In theory, the use-macro replaces the tag, so the defined-macro is never
> defined.  Now, that may not be exactly right.

I don't think it's the same situation. In Willem's case, the ZPT was working
as expected, i.e., METAL statements take precedence over TAL's, and as a
consequence, use-macro would replace everything (and using slots as you
proposed looks more to be METAL's way).

In my case, I got a compiler error message stating I can't use together (in
the same html element) define-macro and use-macro. So, it's an imposed METAL
limitation and essentially a matter of precedence between METAL statements
(no TAL involved).

I've a quite good reason to have define-macro and use-macro together. More
specifically, I'm looking to define a macro which in itself uses a macro.
This provides a sort of html template inheritance. The opposite doesn't make
much sense (using a macro that defines a macro looks irrelevant).

The effect I need is supported ("If the macro body uses any macros, they are
expanded first.", METAL reference). I just would like to avoid using
<metal:block> to get it. Why not have both in the same HTML element?

> It would be nice if we had an Order of Operation list that had METAL
> mixed with TAL.  You can see a TAL only version at
> http://localhost:8080/Control_Panel/Products/PageTemplates/Help/tal.stx
> if you run Zope locally.

TAL and METAL are independent languages (per the Zope Book). I suspect that
something else than the stated "Zope handles macros first when rendering
your templates. Then Zope evaluates TAL expressions." would make the
semantics of both languages too complex, if at all desirable. My newbie 2
cents.

Fernando