Controlling whitespace in Jinja2 templates: Difference between revisions
link to Bloomreach docs |
link to project on GitHub |
||
| Line 28: | Line 28: | ||
In at least v2.9 of Ansible, the Template module has options to specify both. | In at least v2.9 of Ansible, the Template module has options to specify both. | ||
*[https://docs.ansible.com/ansible/2.9/modules/template_module.html 2.9 docs for the template module | *[https://docs.ansible.com/ansible/2.9/modules/template_module.html 2.9 docs for the template module] | ||
*[https://docs.ansible.com/ansible/latest/modules/template_module.html latest docs for the template module] | *[https://docs.ansible.com/ansible/latest/modules/template_module.html latest docs for the template module] | ||
**[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html#parameter-lstrip_blocks parameter lstrip_blocks] | **[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html#parameter-lstrip_blocks parameter lstrip_blocks] | ||
| Line 39: | Line 39: | ||
==By hand== | ==By hand== | ||
I was so frustrated by the lack of clear examples '''that showed all variants''', I created a project on GitHub called '''[https://github.com/freephile/test-jinja test-jinja]''' that does exactly that. (Inspiration from https://github.com/ansible/ansible/pull/37478) | |||
You could also use the [https://github.com/qn7o/jinja2-live-parser jinja2 live parser] project to interactively preview jinja. | |||
If you're confused about Variable notation and how those are defined in templates, see https://jinja.palletsprojects.com/en/3.1.x/templates/#variables | If you're confused about Variable notation and how those are defined in templates, see https://jinja.palletsprojects.com/en/3.1.x/templates/#variables | ||
==Debugging== | ==Debugging== | ||
Just put <code>{% debug %}</code> somewhere in your template file. | Just put <code>{% debug %}</code> somewhere in your template file. This didn't work for me in Ansible 2.9 | ||
== More == | == More == | ||