def render_string(self, filename, **kwargs):
'''Override render_string to use mako template.
Like tornado render_string method, this method
also pass request handler environment to template engine.
'''
try:
template = self._lookup.get_template(filename)
env_kwargs = dict(
handler=self,
request=self.request,
current_user=self.current_user,
locale=self.locale,
_=self.locale.translate,
static_url=self.static_url,
xsrf_form_html=self.xsrf_form_html,
reverse_url=self.application.reverse_url,
)
env_kwargs.update(kwargs)
return template.render(**env_kwargs)
except Exception:
traceback.print_exc()
return exceptions.html_error_template().render()
评论列表
文章目录