starlite.template#
- class starlite.template.TemplateEngineProtocol#
Bases:
Protocol
[T_co
]Protocol for template engines.
- __init__(directory: Union[DirectoryPath, List[DirectoryPath]]) None #
Initialize the template engine with a directory.
- Parameters:
directory – Direct path or list of directory paths from which to serve templates.
- get_template(template_name: str) T_co #
Retrieve a template by matching its name (dotted path) with files in the directory or directories provided. :param template_name: A dotted path
- Returns:
Template instance
- Raises:
TemplateNotFoundException <starlite.exceptions.TemplateNotFoundException> – if no template is found.
- class starlite.template.TemplateProtocol#
Bases:
Protocol
Protocol Defining a
Template
.Template is a class that has a render method which renders the template into a string.
- render(*args: Any, **kwargs: Any) str #
Return the rendered template as a string.
- Parameters:
**kwargs – A string keyed mapping of values passed to the TemplateEngine
- Returns:
The rendered template string
- __init__(*args, **kwargs)#
- starlite.template.__getattr__(name: str) Any #
Provide lazy importing as per https://peps.python.org/pep-0562/