diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-03 00:01:03 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-03 00:06:37 +0300 |
commit | 38934cfb0b963a0157cf16c13499977ac87f35b9 (patch) | |
tree | 124d141726b8a860761a75fe2b597eecce078ee7 /contrib/python/Flask/py3/flask/templating.py | |
parent | 616419d508d3ee4a3b07a82e5cae5ab4544bd1e2 (diff) | |
download | ydb-38934cfb0b963a0157cf16c13499977ac87f35b9.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/Flask/py3/flask/templating.py')
-rw-r--r-- | contrib/python/Flask/py3/flask/templating.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/python/Flask/py3/flask/templating.py b/contrib/python/Flask/py3/flask/templating.py index bb3e7fd5ddb..507615c5ccc 100644 --- a/contrib/python/Flask/py3/flask/templating.py +++ b/contrib/python/Flask/py3/flask/templating.py @@ -131,7 +131,8 @@ def _render(template: Template, context: dict, app: "Flask") -> str: def render_template( - template_name_or_list: t.Union[str, t.List[str]], **context: t.Any + template_name_or_list: t.Union[str, Template, t.List[t.Union[str, Template]]], + **context: t.Any ) -> str: """Renders a template from the template folder with the given context. @@ -143,6 +144,12 @@ def render_template( context of the template. """ ctx = _app_ctx_stack.top + + if ctx is None: + raise RuntimeError( + "This function can only be used when an application context is active." + ) + ctx.app.update_template_context(context) return _render( ctx.app.jinja_env.get_or_select_template(template_name_or_list), @@ -161,5 +168,11 @@ def render_template_string(source: str, **context: t.Any) -> str: context of the template. """ ctx = _app_ctx_stack.top + + if ctx is None: + raise RuntimeError( + "This function can only be used when an application context is active." + ) + ctx.app.update_template_context(context) return _render(ctx.app.jinja_env.from_string(source), context, ctx.app) |