class TemplateStream:
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 string is yielded.
If buffering is enabled with a buffer size of 5, five items are combined into a new string. This is mainly useful if you are streaming big templates to a client via WSGI which flushes after each iteration.
Method | disable_buffering |
Disable the output buffering. |
Method | dump |
Dump the complete stream into a file or file-like object. Per default strings are written, if you want to encode before writing specify an encoding . |
Method | enable_buffering |
Enable buffering. Buffer size items before yielding them. |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __next__ |
Undocumented |
Method | _buffered_generator |
Undocumented |
Instance Variable | _gen |
Undocumented |
Instance Variable | _next |
Undocumented |
Instance Variable | buffered |
Undocumented |
Dump the complete stream into a file or file-like object.
Per default strings are written, if you want to encode
before writing specify an encoding
.
Example usage:
Template('Hello {{ name }}!').stream(name='foo').dump('hello.html')
Parameters | |
fp:t.Union[ | Undocumented |
encoding:t.Optional[ | Undocumented |
errors:t.Optional[ | Undocumented |
size
items before yielding them.Parameters | |
size:int | Undocumented |