[Zope] METAL question: relative reference to a macro defined in the same file

Mark Gibson mark at kaivo.com
Thu Apr 8 17:51:11 EDT 2004


Johan Carlsson wrote:
> 
> Is it possible to refer to a macro defined in the same file
> in a use-macro statement?
> 
> Using:
> <div metal:use-macro="template/macros/render_fields"/>
> doesn't work because template is the main template called not
> necessary the one containing the macro and the use-macro.
> 
> Using:
> <div metal:use-macro="here/pat/to/the/file/macros/render_fields"/>
> does work but if I move the file I need to change the content,
> and that's bade maintainability in my book :-)
> 
> Regards,
> Johan
> 
> 

You can use a python script to return a macro dynamically.  Then just 
call the script instead of the macro:

<html metal:use-macro="here/GetMacro">

or

<html metal:use-macro="python:here.GetMacro('some_named_macro')">


See:

http://www.zopelabs.com/cookbook/1014285275

Mark



More information about the Zope mailing list