Open GriceTurrble opened 1 year ago
I think this really depends on the use case. I want to change the delimiter, as we use cookiecutter currently to template an ansible playbook. As Ansible is using Jinja2 very heavily this would result in messing up the file with {% raw %} tags, also its messing up the ansible-lint run totally.
Description:
From the docs on Jinja2 Custom Delimiters:
While this is technically true (and something Jinja offers so not directly a problem of this project), it's also an anti-pattern. The delimiters should be recognizable to other template authors and users without needing to go into the particulars of the template's config.
Better advice, IMO, would be to wrap their Helm Chart or other similar-syntax files in
{% raw %} ... {% endraw %}
tags. That way it doesn't matter what syntax is used within the file: Jinja will ignoreraw
blocks entirely. Template authors can then add cookiecutter variables into those templates using these tags in reverse:This may end up with slightly-uglier code in the Helm chart, granted; but it allows more progressive adoption of templating in more complex projects without needing to change the delimiter and re-write every previous template file, on top of remembering which non-standard delimiter is required for every new file.