quart.templating module¶
-
class
quart.templating.DispatchingJinjaLoader(app: Quart)¶ Bases:
jinja2.loaders.BaseLoaderQuart specific Jinja2 Loader.
This changes the default sourcing to consider the app and blueprints.
-
get_source(environment: quart.templating.Environment, template: str) → Tuple[str, Optional[str], Callable]¶ Returns the template source from the environment.
This considers the loaders on the
appand blueprints.
-
list_templates() → List[str]¶ Returns a list of all avilable templates in environment.
This considers the loaders on the
appand blueprints.
-
-
class
quart.templating.Environment(app: Quart, **options: Any)¶ Bases:
jinja2.environment.EnvironmentQuart specific Jinja2 Environment.
This changes the default Jinja2 loader to use the DispatchingJinjaLoader, and enables async Jinja by default.
-
async
quart.templating.render_template(template_name_or_list: Union[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.