在mako模板中:在HTML字符串中调用Python函数
我该如何在mako中做到这一点:
<% import cherrypy %>
...
<link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />
AttributeError: 'Undefined' object has no attribute 'url'
1 个回答
3
回答:应该用 <%! import cherrypy %>
,而不是 <% import cherrypy %>
。