mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-07-03 09:08:54 +00:00
Set Jinja2's keep_trailing_newline=True in template_from_string.
Without this setting, the newline idempotence of scalar strings changes depending on whether or not they contain any Jinja2 template blocks.
This commit is contained in:
parent
7c6175e780
commit
7a8eb0b670
3 changed files with 10 additions and 2 deletions
|
|
@ -322,7 +322,7 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False):
|
|||
def my_finalize(thing):
|
||||
return thing if thing is not None else ''
|
||||
|
||||
environment = jinja2.Environment(trim_blocks=True, undefined=StrictUndefined, extensions=_get_extensions(), finalize=my_finalize)
|
||||
environment = jinja2.Environment(trim_blocks=True, keep_trailing_newline=True, undefined=StrictUndefined, extensions=_get_extensions(), finalize=my_finalize)
|
||||
environment.filters.update(_get_filters())
|
||||
environment.template_class = J2Template
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue