]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
add missing options to overlay from __init__
authorTom Brouwer <brouwer@floodtags.com>
Fri, 1 Apr 2022 20:29:09 +0000 (22:29 +0200)
committerDavid Lord <davidism@gmail.com>
Mon, 4 Apr 2022 13:40:57 +0000 (06:40 -0700)
CHANGES.rst
src/jinja2/environment.py

index cec1ad842e55ee100d75d4e60c31c8f3de4c2bc7..da7d0a68237a459f7879637841583090bfefb6f6 100644 (file)
@@ -5,6 +5,9 @@ Version 3.1.2
 
 Unreleased
 
+-   Add parameters to ``Environment.overlay`` to match ``__init__``.
+    :issue:`1645`
+
 
 Version 3.1.1
 -------------
index 9dd455a5267329f878347b8751adfecd7e163da8..ea04e8b44330fe22909a2c875c6601e33bd1ffc2 100644 (file)
@@ -393,6 +393,8 @@ class Environment:
         line_comment_prefix: t.Optional[str] = missing,
         trim_blocks: bool = missing,
         lstrip_blocks: bool = missing,
+        newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = missing,
+        keep_trailing_newline: bool = missing,
         extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = missing,
         optimized: bool = missing,
         undefined: t.Type[Undefined] = missing,
@@ -402,6 +404,7 @@ class Environment:
         cache_size: int = missing,
         auto_reload: bool = missing,
         bytecode_cache: t.Optional["BytecodeCache"] = missing,
+        enable_async: bool = False,
     ) -> "Environment":
         """Create a new overlay environment that shares all the data with the
         current environment except for cache and the overridden attributes.
@@ -413,9 +416,13 @@ class Environment:
         up completely.  Not all attributes are truly linked, some are just
         copied over so modifications on the original environment may not shine
         through.
+
+        .. versionchanged:: 3.1.2
+            Added the ``newline_sequence``,, ``keep_trailing_newline``,
+            and ``enable_async`` parameters to match ``__init__``.
         """
         args = dict(locals())
-        del args["self"], args["cache_size"], args["extensions"]
+        del args["self"], args["cache_size"], args["extensions"], args["enable_async"]
 
         rv = object.__new__(self.__class__)
         rv.__dict__.update(self.__dict__)
@@ -437,6 +444,9 @@ class Environment:
         if extensions is not missing:
             rv.extensions.update(load_extensions(rv, extensions))
 
+        if enable_async is not missing:
+            rv.is_async = enable_async
+
         return _environment_config_check(rv)
 
     @property