Hi
It seems there is a problem with locals in Jinja2 templates. For example, this
works in vanilla Jinja2 environment, but doesn't work in ansible environment
("One or more undefined variables: 'publisher' is undefined"):
{# simplified config.xml.j2 #}
<config>
{% for publisher in item.publishers %}
{% include 'publisher.xml.j2' %}
{% endfor %}
</config>
{# simplified publisher.xml.j2 #}
<report>{{ publisher.report }}</report>
In Jinja2 local variables are passed to the new context with 'l_' prefix. This
prefix is stripped in vanilla environment [1], but that is not true in case of
ansible environment [2]. So in the latter case 'publisher' variable is
available in 'publisher.xml.j2' template as 'l_publisher'.
Is this an intended feature, or should I fill a bug report?
[1]:
https://github.com/mitsuhiko/jinja2/blob/27ffd01f95cad7740497a32b22e4ef9d29762162/jinja2/runtime.py#L67-L69
[2]:
https://github.com/ansible/ansible/blob/14499e8bf3ed10f7818ec67e1f865d68e4a2a60b/lib/ansible/utils/template.py#L177-L184
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2001111395386938%40web1m.yandex.ru.
For more options, visit https://groups.google.com/d/optout.