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