Skip to main content

stream_template

Render a template by name with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view.

def stream_template(
template_name_or_list: str | Template | list[str | Template],
context: t.Any
) - > t.Iterator[str]

Render a template by name with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view.

Parameters

NameTypeDescription
template_name_or_list`strTemplate
contextt.AnyThe variables to make available within the template during rendering.

Returns

TypeDescription
t.Iterator[str]An iterator of strings representing the rendered template content.