cement.ext.ext_jinja2
Cement jinja2 extension module.
Note This extension has an external dependency on jinja2. Cement
explicitly does not include external dependencies for optional
extensions.
In Cement
>=3.0.8you must includecement[jinja2]in your applications dependencies.In Cement
<3.0.8you must includejinja2in your applications dependencies.
- class cement.ext.ext_jinja2.Jinja2OutputHandler(*args: Any, **kw: Any)[source]
Bases:
OutputHandlerThis class implements the OutputHandler interface. It provides text output from template and uses the Jinja2 Templating Language. Please see the developer documentation on Output Handling.
This class has an assumed depency on it’s associated Jinja2TemplateHandler. If sub-classing, you must also sub-class/implement the Jinja2TemplateHandler and give it the same label.
- _setup(app: App) None[source]
Called during application initialization and must
setupthe handler object making it ready for the framework or the application to make further calls to it.- Parameters:
app (instance) – The application object.
- class cement.ext.ext_jinja2.Jinja2TemplateHandler(*args: Any, **kw: Any)[source]
Bases:
TemplateHandlerThis class implements the Template Handler interface. It renders content as template, and supports copying entire source template directories using the Jinja2 Templating Language. Please see the developer documentation on Template Handling.
- load(*args: Any, **kw: Any) Tuple[str | bytes, str, str | None][source]
Loads a template file first from
self.app._meta.template_dirsand secondly fromself.app._meta.template_module. Thetemplate_dirshave presedence.- Parameters:
template_path (str) – The secondary path of the template after either
template_moduleortemplate_dirsprefix (set viaApp.Meta)- Returns:
The content of the template (
str), the type of template (str:directory, ormodule), and the path (str) of the directory or module)- Return type:
- Raises:
cement.core.exc.FrameworkError – If the template does not exist in either the
template_moduleortemplate_dirs.