def render_template(template_name_or_list, **context): """Renders a template from the template folder with the given context.
: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 = _app_ctx_stack.top ctx.app.update_template_context(context) return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list), context, ctx.app)
def render_template(template_name_or_list, **context): """Renders a template from the template folder with the given context. :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 = _app_ctx_stack.top ctx.app.update_template_context(context)
template = None
if _request_ctx_stack.top is not None and \ _request_ctx_stack.top.request.blueprint is not None and \ isinstance(template_name_or_list, string_types): bp = ctx.app.blueprints[_request_ctx_stack.top.request.blueprint] if bp.jinja_loader is not None: try: template = bp.jinja_loader.load(ctx.app.jinja_env, template_name_or_list, ctx.app.jinja_env.globals) except TemplateNotFound: pass
if template is None: template = ctx.app.jinja_env\ .get_or_select_template(template_name_or_list)