Skip to content
Myr

Merge pull request #3190 from EtiennePelletier/jinja2-977

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

Make jinja_options a dict rather than ImmutaleDict

authored by David Lord · committed by GitHub · parents aade460, 957f48a · Browse files · 2 files+27 added−12 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+27 added−12 removed

  • other:+27 added−12 removed

2 files+27 added−12 removed

modified:flask/app.py+22 added-10 removed
296 unmodified lines
297 #:298 #: .. versionadded:: 0.10299 json_decoder = json.JSONDecoder300301 #: Options that are passed directly to the Jinja2 environment.302 jinja_options = ImmutableDict(303 extensions=["jinja2.ext.autoescape", "jinja2.ext.with_"]304 )301 #: Options that are passed to the Jinja environment in302 #: :meth:`create_jinja_environment`. Changing these options after303 #: the environment is created (accessing :attr:`jinja_env`) will304 #: have no effect.305 #:306 #: .. versionchanged:: 1.1.0307 #: This is a ``dict`` instead of an ``ImmutableDict`` to allow308 #: easier configuration.309 #:310 jinja_options = {"extensions": ["jinja2.ext.autoescape", "jinja2.ext.with_"]}311312 #: Default configuration parameters.313 default_config = ImmutableDict(314 {
352 unmodified lines
667 return create_logger(self)668669 @locked_cached_property670 def jinja_env(self):665 """The Jinja2 environment used to load templates."""671 """The Jinja environment used to load templates.672673 The environment is created the first time this property is674 accessed. Changing :attr:`jinja_options` after that will have no675 effect.676 """677 return self.create_jinja_environment()678679 @property680 def got_first_request(self):
68 unmodified lines
749 )750 del _get_templates_auto_reload, _set_templates_auto_reload751752 def create_jinja_environment(self):742 """Creates the Jinja2 environment based on :attr:`jinja_options`743 and :meth:`select_jinja_autoescape`. Since 0.7 this also adds744 the Jinja2 globals and filters after initialization. Override745 this function to customize the behavior.753 """Create the Jinja environment based on :attr:`jinja_options`754 and the various Jinja-related methods of the app. Changing755 :attr:`jinja_options` after this will have no effect. Also adds756 Flask-related globals and filters to the environment.757747 .. versionadded:: 0.5758 .. versionchanged:: 0.11759 ``Environment.auto_reload`` set in accordance with760 ``TEMPLATES_AUTO_RELOAD`` configuration option.761762 .. versionadded:: 0.5763 """764 options = dict(self.jinja_options)765766 if "autoescape" not in options:
1641 unmodified lines
modified:CHANGES.rst+5 added-2 removed
2 unmodified lines
3Flask Changelog4===============567Version 1.18-----------7Version 1.1.08-------------910Unreleased1112- :meth:`flask.RequestContext.copy` includes the current session
10 unmodified lines
23- :func:`open_resource` accepts the "rt" file mode. This still does24 the same thing as "r". :issue:`3163`25- The :attr:`MethodView.methods` attribute set in a base class is used26 by subclasses. :issue:`3138`27- :attr:`Flask.jinja_options` is a ``dict`` instead of an28 ``ImmutableDict`` to allow easier configuration. Changes must still29 be made before creating the environment. :pr:`3190`3031.. _#2935: https://github.com/pallets/flask/issues/293532.. _#2957: https://github.com/pallets/flask/issues/295733.. _#2994: https://github.com/pallets/flask/pull/2994
947 unmodified lines