开发者

In mako template: call python function within html string

开发者 https://www.devze.com 2023-01-21 12:26 出处:网络
How do I do this in mako: <% import开发者_如何学编程 cherrypy %> ... <link rel=\"stylesheet\" href=\"${cherrypy.url(\'/media/layout.css\')}\" type=\"text/css\" />

How do I do this in mako:

<% import开发者_如何学编程 cherrypy %>
...
<link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />

AttributeError: 'Undefined' object has no attribute 'url'


Answer: Instead of <% import cherrypy %> one needs <%! import cherrypy %>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号