In Jinja2, is it possible to have a Node
from the AST render after all include
statements have completed?
This is a key piece of a solution
Jinja2 does streaming of template data. The template is evaluated instruction for instruction into a stream of smaller strings that gets concatenated into an actual unicode string by the render()
method. However you can also get hold of the stream by calling into generate()
instead of render()
.
With some in-band signalling and postprocessing of the stream one might probably be able to implement something like that, but it's against the way of how Jinja2 was designed so it might break horribly and is totally unsupported.