[ZPT] Re: Passing Parameters to Templates

Tonico Strasser contact_tonico at yahoo.de
Thu Oct 28 11:13:14 EDT 2004


Philip Kilner wrote:
> Hi All,
> 
> I've written a macro to do some formatting of a value - but how can I 
> pass the value to the template in my "metal:use-macro" statement?
> 

If you have a template 'my_macros' ...
---
<div metal:define-macro="x">
   <div tal:content="y"/>
</div>
---

... and you use the above macro in another template ...
---
<div tal:define="y string:test" tal:omit-tag="">
   <div metal:use-macro="here/my_macros/macros/x"/>
</div>
---

... the output will be:
---
<div>
   <div>test</div>
</div>
---

You don't need to pass the value to the macro.

HTH
Tonico



More information about the ZPT mailing list