|
|
|
@ -109,17 +109,19 @@ def _render(template, context, app):
|
|
|
|
|
return rv |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def render_template(template_name, **context): |
|
|
|
|
def render_template(template_name_or_list, **context): |
|
|
|
|
"""Renders a template from the template folder with the given |
|
|
|
|
context. |
|
|
|
|
|
|
|
|
|
:param template_name: the name of the template to be rendered |
|
|
|
|
:param template_name_or_list: the name of the template to be |
|
|
|
|
rendered, or an iterable with template names |
|
|
|
|
the first one existing will be rendered |
|
|
|
|
:param context: the variables that should be available in the |
|
|
|
|
context of the template. |
|
|
|
|
""" |
|
|
|
|
ctx = _request_ctx_stack.top |
|
|
|
|
ctx.app.update_template_context(context) |
|
|
|
|
return _render(ctx.app.jinja_env.get_template(template_name), |
|
|
|
|
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list), |
|
|
|
|
context, ctx.app) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|