Powered by Tachyonic Project Luxon Framework v1.4.0

Luxon Framework for rapid application development. (luxon)


Templating Engine

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.

There are two places for templates to exist:
  • Python package.
  • File system. These are known as overrides.

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

Direct interface

You can use the templating engine directly with the templates by using Environment class from luxon.core.template.

Environment Class

class luxon.core.template.Environment(loader)[source]

Wraps around the Jinja2 Environment class with TachyonicLoader() specified as the loader for this environment

Tachyonic Loader Class

class luxon.core.template.TachyonicLoader(app_path)[source]

Jinja class for loading templates.

get_source(environment, template)[source]

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

luxon.helpers.template.render_template(template, *args, rst2html=False, **kwargs)[source]

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.
jinja2 rendered template with supplied args and kwargs.