Mako 文档中的以下示例实际上不起作用:
<%
x = 12
%>
<%def name="outer()">
<%
y = 15
%>
<%def name="inner()">
inner, x is ${x}, y is ${y}
</%def>
outer, x is ${x}, y is ${y}
</%def>
当我在<%self:outer />
下面添加调用def(文件中没有其他内容)时,页面将出错并且我的apache日志显示
[Sun Dec 02 13:25:08 2012] [error] [client 89.247.172.1] File "/tmp/mako_template_cache/index.html.mako.py", line 82, in render_outer
[Sun Dec 02 13:25:08 2012] [error] [client 89.247.172.1] __M_writer(str(x))
[Sun Dec 02 13:25:08 2012] [error] [client 89.247.172.1] File "/usr/lib/python3/dist-packages/mako/runtime.py", line 195, in __str__
[Sun Dec 02 13:25:08 2012] [error] [client 89.247.172.1] raise NameError("Undefined")
[Sun Dec 02 13:25:08 2012] [error] [client 89.247.172.1] NameError: Undefined
我可能做错了什么?我有来自 Debian 的 Mako 0.7.0,它应该可以工作。