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.


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


has_source_access bool(x) -> bool


class ChoiceLoader

Method details

get_source(environment, template)

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