![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|
Public Member Functions | |
| None | __init__ (self, t.Iterator[str] gen) |
| None | dump (self, t.Union[str, t.IO[bytes]] fp, t.Optional[str] encoding=None, t.Optional[str] errors="strict") |
| None | disable_buffering (self) |
| None | enable_buffering (self, int size=5) |
| "TemplateStream" | __iter__ (self) |
| str | __next__ (self) |
Public Attributes | |
| buffered | |
Static Public Attributes | |
| template_class | |
Protected Member Functions | |
| t.Iterator[str] | _buffered_generator (self, int size) |
Protected Attributes | |
| _gen | |
| _next | |
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.
| None jinja2.environment.TemplateStream.disable_buffering | ( | self | ) |
Disable the output buffering.
| None jinja2.environment.TemplateStream.dump | ( | self, | |
| t.Union[str, t.IO[bytes]] | fp, | ||
| t.Optional[str] | encoding = None, |
||
| t.Optional[str] | errors = "strict" |
||
| ) |
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')
| None jinja2.environment.TemplateStream.enable_buffering | ( | self, | |
| int | size = 5 |
||
| ) |
Enable buffering. Buffer `size` items before yielding them.