代码之家  ›  专栏  ›  技术社区  ›  tauran

在mako模板中:在html字符串中调用python函数

  •  2
  • tauran  · 技术社区  · 14 年前

    在mako我该怎么做:

    <% import cherrypy %>
    ...
    <link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />
    
    AttributeError: 'Undefined' object has no attribute 'url'
    
    1 回复  |  直到 9 年前
        1
  •  3
  •   tauran    14 年前

    回答:而不是 <% import cherrypy %> <%! import cherrypy %>