【发布时间】:2011-04-29 19:18:08
【问题描述】:
我如何在 mako 中做到这一点:
<% import cherrypy %>
...
<link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />
AttributeError: 'Undefined' object has no attribute 'url'
【问题讨论】:
-
您是否尝试过导入其他内容,例如数学? >>> t = Template('Result: ${math.sqrt(9)}') >>> t.render() 'Result: 3.0'
-
我知道了:你需要
<%! ... %> -
@atomocopter 你把那个解决方案写成一个正确的答案怎么样,然后 tauran 可以接受它,以后用户不必通过 cmets 来找到解决方案(你在这个过程中会有所收获); )