Ignore before_render_template return values

This commit is contained in:
Alexander Pantyukhin 2015-04-07 07:18:15 +00:00 committed by Markus Unterwaditzer
parent 883f82f261
commit 5e12748d0e
2 changed files with 2 additions and 33 deletions

View file

@ -101,20 +101,9 @@ class DispatchingJinjaLoader(BaseLoader):
def _render(template, context, app):
"""Renders the template and fires signals.
It is possible to override render template in the before_render_template signal.
It can be done only if exactly one receiver and it return not None result."""
brt_resp = before_render_template.send(app, template=template, context=context)
overrides = [rv for _, rv in brt_resp if rv is not None]
if len(overrides) == 1:
return overrides[0]
elif len(overrides) > 1:
raise RuntimeError('More than one before_render_template signal '
'returned data')
"""Renders the template and fires the signal"""
before_render_template.send(app, template=template, context=context)
rv = template.render(context)
template_rendered.send(app, template=template, context=context)
return rv