Skip to content

Fix include without context in macros#2161

Open
kljnepk wants to merge 7 commits intopallets:stablefrom
kljnepk:include-without-context-macro
Open

Fix include without context in macros#2161
kljnepk wants to merge 7 commits intopallets:stablefrom
kljnepk:include-without-context-macro

Conversation

@kljnepk
Copy link
Copy Markdown

@kljnepk kljnepk commented Apr 13, 2026

Fixes #2108

visit_Include currently uses yield from template._get_default_module()._body_stream
in the sync without context branch unconditionally.

That is fine for unbuffered output, but inside buffered frames such as macros it turns
the generated macro into a generator function, so rendering returns the generator repr
instead of the included template output.

This keeps the existing yield from path for unbuffered frames and switches buffered
frames to explicit iteration so included output is appended to the frame buffer instead.

Adds a regression test for {% include "included" without context %} inside a macro.

@kljnepk kljnepk marked this pull request as ready for review April 14, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant