[Zope3-dev] Re: New METAL extension feature

Alec Munro alecmunro at gmail.com
Tue Nov 30 13:48:58 EST 2004


On Mon, 22 Nov 2004 12:38:31 -0700 (MST), shane at hathawaymix.org
<shane at hathawaymix.org> wrote:
> 
> 
> On Mon, 22 Nov 2004, Tonico Strasser wrote:
> 
> > A suggestion: to avoid confusion about why metal:define-macro works different
> > when used together with metal:use-macro I would call it metal:extend-macro or
> > similar.
> >
> > <html metal:extend-macro="context/@@coolskin_macros/page">
> 
> I thought about adding to the language, but I didn't want to incur the
> wrath of ZPT users by suggesting a new attribute.  Besides, you really
> need to state both the source of the macro being extended and the name of
> the macro being defined.  You can infer the name from the last part of the
> path, but TAL is nice and explicit now and I don't want to muck it up.
> 
> You're on target, though.  The implementation compiles macro extensions
> using a new bytecode called "extendMacro".
> 
> This really doesn't change define-macro.  When there is a use-macro and
> define-macro in the same tag, the use-macro defines the behavior of the
> tag, while define-macro, as always, has no effect on the output of the
> template.
> 
> Shane
> 
> 
> _______________________________________________
> Zope3-dev mailing list
> Zope3-dev at zope.org
> Unsub: http://mail.zope.org/mailman/options/zope3-dev/alecmunro%40gmail.com
> 
> 

(Sorry about the late response)
So if I have this correct. 
Previously, if you wanted to extend a macro, you would use a facade
(I'm not sure if that is the official language), and in that case, you
had to both fill and define all the slots in your facade that were
defined in your original macro.
Currently, the situation is similar, but you only fill and define the
slots that you wish to change. The other slots are passed through to
templates that call the macro.

This seems like a very positive change in terms of reducing busy work
for template developers. Any chance will see this backported to 2.8?
It could certainly be useful.

I do wonder about one thing though. In my facades, I would often have
a section like the following:

<span metal:fill-slot="style">
 <link rel="stylesheet" href="somestyle.css" />
 <span metal:define-slot="style"></span>
</span>

What happens in this circumstance? What happens if I define a new slot
within a fill slot?

Thanks for this change, I'm betting it will become a very useful pattern.

Alec Munro


More information about the Zope3-dev mailing list