我想使用带有金字塔+ZPT 引擎(变色龙)的宏。
文档说“一个页面模板可以容纳多个宏”。 http://chameleon.readthedocs.org/en/latest/reference.html#macros-metal
因此我定义了一个文件
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>
和一个全局模板main_template.pt,其中包含定义 slot 的所有 html 内容content。
progress.pt以及用于main_template.pt填充插槽的我的视图模板:
<html metal:use-macro="load: main_template.pt">
<div metal:fill-slot="content">
...
<div metal:use-macro="step-0"></div>
...
</div>
</html>
到目前为止,我痛苦地发现,我不能说use-macro="main_template.pt"是因为 Chameleon 不像 Zope 那样自动加载模板。因此,我必须先添加load:片段。
来到use-macro="step-0". 这会引发 NameError step-0。我试图用类似的macros.pt东西预加载,<tal:block tal:define="compile load: macros.pt" />但这没有帮助。
如何使用宏摘要文件中收集的宏?