Skip to content
Myr

error for render_template outside app context

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yourun-Proger · committed by David Lord · parent 7096b2c · Browse files · 2 files+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−0 removed

  • other:+15 added−0 removed

2 files+15 added−0 removed

modified:src/flask/templating.py+12 added
142 unmodified lines
143 :param context: the variables that should be available in the144 context of the template.145 """146 ctx = _app_ctx_stack.top147148 if ctx is None:149 raise RuntimeError(150 "This function can only be used when an application context is active."151 )152153 ctx.app.update_template_context(context)154 return _render(155 ctx.app.jinja_env.get_or_select_template(template_name_or_list),156 context,
10 unmodified lines
167 :param context: the variables that should be available in the168 context of the template.169 """170 ctx = _app_ctx_stack.top171172 if ctx is None:173 raise RuntimeError(174 "This function can only be used when an application context is active."175 )176177 ctx.app.update_template_context(context)178 return _render(ctx.app.jinja_env.from_string(source), context, ctx.app)
modified:CHANGES.rst+3 added
8 unmodified lines
9 commands. :pr:`4606`10- Relax type annotation for ``after_request`` functions. :issue:`4600`11- ``instance_path`` for namespace packages uses the path closest to12 the imported submodule. :issue:`4600`13- Clearer error message when ``render_template`` and14 ``render_template_string`` are used outside an application context.15 :pr:`4693`161718Version 2.1.219-------------
1280 unmodified lines