ChoiceLoader Class

Inheritance diagram of ChoiceLoader

class ChoiceLoader(loaders)

This loader works like the PrefixLoader just that no prefix is specified. If a template could not be found by one loader the next one is tried.

>>> loader = ChoiceLoader([
...     FileSystemLoader('/path/to/user/templates'),
...     FileSystemLoader('/path/to/system/templates')
... ])

This is useful if you want to allow users to override builtin templates from a different location.

Methods

__init__(loaders)
get_source(environment, template)
list_templates()
load(environment, name[, globals]) Loads a template.

Attributes

has_source_access bool(x) -> bool

Descriptions

class ChoiceLoader

Method details

__init__(loaders)
get_source(environment, template)
list_templates()

Inherited member details

load(environment, name, globals=None)

Loads a template. This method looks up the template in the cache or loads one by calling get_source(). Subclasses should not override this method as loaders working on collections of other loaders (such as PrefixLoader or ChoiceLoader) will not call this method but get_source directly.

has_source_access = True

Table Of Contents

Previous topic

BaseLoader Class

Next topic

DictLoader Class