Luxon provides templating engine interface to Jinja2. Our interface only inherits from Jinja2 and extends the functionality needed in the framework. The loader will ensure that templates are found in the correct places.
We have overrides so that users using your application can customize the templates to be rendered.
By looking at the following example we will describe the process:
from luxon import render_template render_template('package/stuff/template.html', name='Foo')
The loader will first attempt to find the an override in the appplication root. for example /var/www/app/templates/package/stuff/template.html.
When there is no such template it will look import package. for example it will look inside package: templates/stuff/template.html
You can use the templating engine directly with the templates by using Environment class from luxon.core.template.
Wraps around the Jinja2 Environment class with TachyonicLoader() specified as the loader for this environment
Jinja class for loading templates.
Get raw template for environment.
First attempts to load overriding template then uses template within specified package. For example “package/template.html”
Returns a list of overiding templates for this environment.
Overiding templates are located within wsgi application installation path in templates.
Templates to override are located in package/templates path structure. For example /var/www/ui/templates/template.html
Returns a list of templates for this environment.
Templates are located within the python package source.
render_template(template, *args, rst2html=False, **kwargs)¶
Function to return a jinja2 rendered template.
Imports the Environment class from luxon.core.template only when required, in order to imporve performance as jinja2 libraries are low to import.
|Parameters:||template (str) – filename of template to render.|