class documentation
class TemplateStream: (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 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 | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __next__ |
Undocumented |
Method | disable |
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 |
Enable buffering. Buffer `size` items before yielding them. |
Instance Variable | buffered |
Undocumented |
Method | _buffered |
Undocumented |
Instance Variable | _gen |
Undocumented |
Instance Variable | _next |
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 |