mako¶
- class litestar.contrib.mako.MakoTemplate[source]¶
Bases:
TemplateProtocolMako template, implementing
TemplateProtocol
- class litestar.contrib.mako.MakoTemplateEngine[source]¶
Bases:
TemplateEngineProtocol[MakoTemplate,Mapping[str,Any]]Mako-based TemplateEngine.
- __init__(directory: Path | list[Path] | None = None, engine_instance: Any | None = None) None[source]¶
Initialize template engine.
- get_template(template_name: str) MakoTemplate[source]¶
Retrieve a template by matching its name (dotted path) with files in the directory or directories provided.
- Parameters:
template_name¶ – A dotted path
- Returns:
MakoTemplate instance
- Raises:
TemplateNotFoundException – if no template is found.
- register_template_callable(key: str, template_callable: Callable[[Concatenate[Mapping[str, Any], P]], T]) None[source]¶
Register a callable on the template engine.
- render_string(template_string: str, context: Mapping[str, Any]) str[source]¶
Render a template from a string with the given context.
- classmethod from_template_lookup(template_lookup: TemplateLookup) MakoTemplateEngine[source]¶
Create a template engine from an existing mako TemplateLookup instance.
- Parameters:
template_lookup¶ – A mako TemplateLookup instance.
- Returns:
MakoTemplateEngine instance