class jinja2.environment.TemplateStream(gen)[source]

A template stream works pretty much like an ordinary python generator but it can buffer multiple items to reduce the number of total iterations. Per default the output is unbuffered which means that for every unbuffered instruction in the template one unicode string is yielded.

If buffering is enabled with a buffer size of 5, five items are combined into a new unicode string. This is mainly useful if you are streaming big templates to a client via WSGI which flushes after each iteration.


disable_buffering() Disable the output buffering.
dump(fp[, encoding, errors]) Dump the complete stream into a file or file-like object.
enable_buffering([size]) Enable buffering.