jinja2.FunctionLoader

class jinja2.FunctionLoader(load_func)[source]

A loader that is passed a function which does the loading. The function receives the name of the template and has to return either an unicode string with the template source, a tuple in the form (source, filename, uptodatefunc) or None if the template does not exist.

>>> def load_template(name):
...     if name == 'index.html':
...         return '...'
...
>>> loader = FunctionLoader(load_template)

The uptodatefunc is a function that is called if autoreload is enabled and has to return True if the template is still up to date. For more details have a look at BaseLoader.get_source() which has the same return value.

Methods

__init__(load_func)
get_source(environment, template)
list_templates() Iterates over all templates.
load(environment, name[, globals]) Loads a template.

Attributes

has_source_access