[ZPT] Some Macros Questions/Suggestions

Evan Simpson evan@zope.com
Mon, 04 Mar 2002 12:28:08 -0500


Chris Withers wrote:
> 2. In macro templates, where does here bind to?

All use-macro-ed code operates in exactly the same context as the code 
it is expanded into.  So, not only are 'here' and 'template' the same as 
  in surrounding (and fill-slot) code, so are tal:define-d variables. 
This allows loose "parameterization" of macros, as Dieter has pointed out.

> 3. Is there any reason why define-macro and fill-slot aren't allowed on the same tag? It
> would be cool for recursive definey things...

Simplicity of implementation, and nobody has really worked out in detail 
how all the metal statements should really interact on the same tag.

> 4. How hard would it be to implement a fill-attribute thing so that the following would
> work:
> 
> <body metal:define-attribute="bgcolor" bgcolor="#FFFFFF">
> <body metal:fill-attribute="bgcolor string:#FEFEFE">
Looks simple to a human, but potentially tricky for code.  Consider the 
following:

[Macro]
<a href="foo" metal:define-attribute="href">Foo!</a>
...
<a href="bar" metal:define-attribute="href">Bar!</a>

[Use Macro]
<a href="foo">Foo!</a>
...
<a href="bar" metal:fill-attribute="href string:notbar">Bar!</a>

We see an "obvious" interpretation, and it might even be able to be 
rigorously defined, but I'm not up for it.

Cheers,

Evan @ Zope