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.8
you must includecement[jinja2]
in your applications dependencies.In Cement
<3.0.8
you must includejinja2
in your applications dependencies.
- class cement.ext.ext_jinja2.Jinja2OutputHandler(*args, **kw)[source]
Bases:
OutputHandler
This 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.
- _setup(app)[source]
Called during application initialization and must
setup
the 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, **kw)[source]
Bases:
TemplateHandler
This 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, **kw)[source]
Loads a template file first from
self.app._meta.template_dirs
and secondly fromself.app._meta.template_module
. Thetemplate_dirs
have presedence.- Parameters:
template_path (str) – The secondary path of the template after either
template_module
ortemplate_dirs
prefix (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_module
ortemplate_dirs
.