I want to use macros with pyramid+ZPT engine (Chameleon).
The docs say that "A single Page Template can accommodate multiple macros." http://chameleon.readthedocs.org/en/latest/reference.html#macros-metal
Thus I defined a file
macros.pt
:
<div metal:define-macro="step-0">
<p>This is step 0</p>
</div>
<div metal:define-macro="step-1">
<p>This is step 1</p>
</div>
and a global template main_template.pt
with all the html stuff defining a slot content
.
and a template for my view progress.pt
which uses main_template.pt
to fill in the slot:
<html metal:use-macro="load: main_template.pt">
<div metal:fill-slot="content">
...
<div metal:use-macro="step-0"></div>
...
</div>
</html>
So far I painfully found out, that I can not just say use-macro="main_template.pt"
because Chameleon does not load templates automatically as Zope does. Thus I had to add the load:
snippet before.
Coming to use-macro="step-0"
. This raises NameError for step-0
. I tried to preload the macros.pt
with something like <tal:block tal:define="compile load: macros.pt" />
but this didn't help.
How can I use macros which are gathered in a macros summary file?