mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge branch 'devel' of https://github.com/leverich/ansible into leverich-devel
This commit is contained in:
commit
42b5294820
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):
|
def my_finalize(thing):
|
||||||
return thing if thing is not None else ''
|
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.filters.update(_get_filters())
|
||||||
environment.template_class = J2Template
|
environment.template_class = J2Template
|
||||||
|
|
||||||
|
|
|
@ -63,4 +63,10 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "file_result.changed != True"
|
- "file_result.changed != True"
|
||||||
|
|
||||||
|
# VERIFY STRING TEMPLATE PRESERVES NEWLINE
|
||||||
|
|
||||||
|
- name: ensure template strings preserve newline
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "newline_no_template_string == newline_template_string"
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
templated_var: templated_var_loaded
|
templated_var: templated_var_loaded
|
||||||
|
newline_template_string: "Hello {{ 'World' }}\n"
|
||||||
|
newline_no_template_string: "Hello World\n"
|
||||||
|
|
Loading…
Reference in a new issue