When I use include ... without context inside a macro like this:
import jinja2
print(
jinja2.Environment(
loader=jinja2.DictLoader(
{
"included": "foo",
"main": """
{%- macro foo() %}
{%- include "included" without context %}
{%- endmacro %}
{{- foo() -}}
""",
}
),
)
.get_template("main")
.render()
)
The macro evaluates to something that looks like a repr() string instead of the contents of the included template:
$ python3 foo.py
<generator object root.<locals>.macro at 0x7f79f60a0580>
The same include line works outside of a macro, and it works inside the macro if I remove without context:
Environment:
- Python version: 3.13.5
- Jinja version: 3.1.6-1
When I use
include ... without contextinside a macro like this:The macro evaluates to something that looks like a
repr()string instead of the contents of the included template:The same
includeline works outside of a macro, and it works inside the macro if I removewithout context:Environment: