[ZPT] fill-slot only works in immediately enclosing use-macro?

Evan Simpson evan@zope.com
Mon, 03 Dec 2001 16:22:17 -0500


Brad Clements wrote:

> I'm trying to fill a slot defined in a macro that is called from a macro, called from a 
> macro, which is called from a body where the fill-slot is included. The slot doesn't seem 
> to be filled.


That's quite a sentence ;-)

> Am I doing something wrong, or is this a limitation of slots?

If macro M1 uses macro M2, and macro M2 has slot S2, then either M1 fills 
this slot or it doesn't.  In either case, users of M1 have no opportunity to 
get at S2.

You can re-define the slot in M1, either with the same name or a different 
one, like so:

<span metal:fill-slot="S2" metal:define-slot="S2">redefined</span>

Now, users of M1 can fill S2.

There are a couple of problems with the current setup that I hope to address 
in the next release. In particular, there is no way to explicitly spell "I 
am not filling slot S2".  I plan to introduce a statement, possibly called 
"metal:keep-slot", for this purpose.  Then you could write:

<span metal:keep-slot="S2" metal:define-slot="S2">redefined</span>

...in order to "pass through" a slot definition.  Without the "define-slot", 
this would preserve the default contents of S2, but not make the slot 
available to users of M1.

Cheers,

Evan @ Zope