mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
When using ANSIBLE_JINJA2_NATIVE bypass our None filtering in _finalze (#41408)
* When using ANSIBLE_JINJA2_NATIVE bypass our None filtering in _finalize. Fixes #41392 * Add tests for _finalize bypass * Address python3 failures in tests
This commit is contained in:
parent
46ae1a343a
commit
ad0827e5c0
6 changed files with 26 additions and 8 deletions
|
@ -609,8 +609,13 @@ class Templar:
|
|||
|
||||
def _finalize(self, thing):
|
||||
'''
|
||||
A custom finalize method for jinja2, which prevents None from being returned
|
||||
A custom finalize method for jinja2, which prevents None from being returned. This
|
||||
avoids a string of ``"None"`` as ``None`` has no importance in YAML.
|
||||
|
||||
If using ANSIBLE_JINJA2_NATIVE we bypass this and return the actual value always
|
||||
'''
|
||||
if USE_JINJA2_NATIVE:
|
||||
return thing
|
||||
return thing if thing is not None else ''
|
||||
|
||||
def _fail_lookup(self, name, *args, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue