0
編譯模板有了這個屬性來獲取類的Jinja2實例webapp2_extras.jinja2從可變
@webapp2.cached_property
def jinja2(self):
# Returns an instance of :class:`Jinja2` from the app registry.
return jinja2.get_jinja2(app=self.app)
參考:http://webapp-improved.appspot.com/api/webapp2_extras/jinja2.html
我能看到的是,返回類具有模塊的模板,但我不知道如何導入它。
我希望能夠加載該模塊走出返回類的所以像我可以做一些事情:temp = Template('{{name}}')
幫助表示讚賞!
你可以 '進口Jinja2的',沒有必要與sys.modules中亂 – Greg 2013-04-06 15:51:08