j2 child template renders but parent does not

5 views
Skip to first unread message

dutu.a...@gmail.com

unread,
Jul 2, 2024, 7:58:31 PM (5 hours ago) Jul 2
to Ansible Project
Hello,

I have a j2 template that looks like this:

---
text text
{% block filter %}{% endblock %}
---

and a child template that extends it:
---
{% extends 'parent.j2' %}
{% block filter %} add filter here {% endblock %}

Now in another template I have this:

{{ lookup ('template', template_name) }}
and i have some ifs to set the template name either to the parent or the child.

Now here comes the really weird part. If I use the child template here, everything works well. If i use the parent I get this error:

unsupported operand type(s) for +=: 'dict' and 'str' 

How can it render the child which also contains the parent but not the parent? I've been trying to fix this for days but nothing works. The error message is very weird as well, I have no idea where the issue is. Seems like maybe something in the python code.

Thanks!

dutu.a...@gmail.com

unread,
Jul 2, 2024, 8:20:24 PM (4 hours ago) Jul 2
to Ansible Project
Forgot to add: ansible version 2.14.3, jinja2 version 2.10.1
Reply all
Reply to author
Forward
0 new messages