You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defrender_template(template_file, **context):
"""Renders template using provided template environment. """ifhasattr(self, 'template_env'):
t_env=self.template_env# tornado template loader do not have method "get_template", and tornado template do not have method "render"template=t_env.get_template(template_file)
body=template.render(**contextor {})
returnbody
hardcode patch for tornado (can work for tornado but not beautiful):
defrender_template(template_file, **context):
"""Renders template using provided template environment. """ifhasattr(self, 'template_env'):
t_env=self.template_env# !!! just for demostration, here I omit the processing code of other templates: jinja2, mako, .# temporary patch for tornadotemplate=t_env.load(template_file)
body=template.generate(**contextor {})
returnbody
May be a better way is to adapt tornado loader in
function "load_tornado_env" of file "templating.py"
Any smarter patch suggest?
The text was updated successfully, but these errors were encountered:
classTornadoRendering(WebMessageHandler):
"""TornadoRendering is a mixin for for loading a Tornado rendering environment. Follows usual convention: 200 => success and 500 => failure The unusual convention of an underscore in front of a variable is used to avoid conflict with **context. '_status_code', for now, is a reserved word. """defrender_template(self, template_file,
_status_code=WebMessageHandler._SUCCESS_CODE,
**context):
"""Renders payload as a tornado template """#### patch starts here ########ifself.application.template_env:
template=self.application.template_env.load(template_file)
body=template.generate(**contextor {})
else:
body=''# body = self.application.render_template(template_file, **context or {})#### patch ends here ########self.set_body(body, status_code=_status_code)
returnself.render()
Tornado loader could not render template and app exit when I tried demo_tornado.py. ( easy regenerated)
Finally I located problems here.
tornado template loader do not have method "get_template", and tornado template do not have method "render"
https://github.com/j2labs/brubeck/blob/master/brubeck/request_handling.py#L702
hardcode patch for tornado (can work for tornado but not beautiful):
May be a better way is to adapt tornado loader in
function "load_tornado_env" of file "templating.py"
Any smarter patch suggest?
The text was updated successfully, but these errors were encountered: