1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/template
Alex Tsitsimpis c3ab6cb9b1 template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478)
* template: Add integration tests for `lstrip_blocks'

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Fix passing `trim_blocks' inline

Fix passing `trim_blocks' option to the template module as inline
argument. Previously passing the `trim_blocks' option inline instead of
using the YAML dictionary format resulted in it always being set to
`True', even if `trim_blocks=False' was used.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Add option to `lstrip_blocks'

Add option to set `lstrip_blocks' when using the template module to
render Jinja templates. The Jinja documentation suggests that
`trim_blocks' and `lstrip_blocks' is a great combination and the
template module already provides an option for `trim_blocks'.

Note that although `trim_blocks' in Ansible is enabled by default since
version 2.4, in order to avoid breaking things keep `lstrip_blocks'
disabled by default. Maybe in a future version it could be enabled by
default.

This seems to address issue #10725 in a more appropriate way than the
suggested.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Add integration tests for `trim_blocks'

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Check Jinja2 support for `lstrip_blocks'

Since the `lstrip_blocks' option was added in Jinja2 version 2.7, raise
an exception when `lstrip_blocks' is set but Jinja2 does not support it.
Check support for `lstrip_blocks' option by checking `jinja2.defaults'
for `LSTRIP_BLOCKS' and do not use `jinja2.__version__' because the
latter is set to `unknown' in some cases, perhaps due to bug in
`pkg_resources' in Python 2.6.6.

Also update option description to state that Jinja2 version >=2.7 is
required.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>
2018-03-23 12:05:21 -04:00
..
files template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
meta
tasks template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
templates template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
vars Don't restrict local jinja2 variables to those that start with l_ 2017-01-20 07:15:51 -06:00
aliases Initial ansible-test implementation. (#18556) 2016-11-29 21:21:53 -08:00
runme.sh Check that AnsibleUndefinedVariable doesn't occur when an unused variable references an undefined variable (#35571) 2018-02-02 09:25:13 -08:00
template.yml Check that AnsibleUndefinedVariable doesn't occur when an unused variable references an undefined variable (#35571) 2018-02-02 09:25:13 -08:00