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