quart.templating module#
- class quart.templating.Environment(app: Quart, **options: Any)#
Bases:
Environment
Quart specific Jinja Environment.
This changes the default Jinja loader to use the DispatchingJinjaLoader, and enables async Jinja by default.
- async quart.templating.render_template(template_name_or_list: str | list[str], **context: Any) str #
Render the template with the context given.
- Parameters:
template_name_or_list – Template name to render of a list of possible template names.
context – The variables to pass to the template.
- async quart.templating.render_template_string(source: str, **context: Any) str #
Render the template source with the context given.
- Parameters:
source – The template source code.
context – The variables to pass to the template.
- async quart.templating.stream_template(template_name_or_list: str | Template | list[str | Template], **context: Any) AsyncIterator[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:
template_name_or_list – The name of the template to render. If a list is given, the first name to exist will be rendered.
context – The variables to make available in the template.
- async quart.templating.stream_template_string(source: str, **context: Any) AsyncIterator[str] #
Render a template from the given source with the context as a stream.
This returns an iterator of strings, which can be used as a streaming response from a view.
- Parameters:
source – The source code of the template to render.
context – The variables to make available in the template.