PrefixLoader Class

Inheritance diagram of PrefixLoader

class PrefixLoader(mapping, delimiter='/')

A loader that is passed a dict of loaders where each loader is bound to a prefix. The prefix is delimited from the template by a slash per default, which can be changed by setting the delimiter argument to something else:

loader = PrefixLoader({
    'app1':     PackageLoader('mypackage.app1'),
    'app2':     PackageLoader('mypackage.app2')

By loading 'app1/index.html' the file from the app1 package is loaded, by loading 'app2/index.html' the file from the second.


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


has_source_access bool(x) -> bool


class PrefixLoader

Method details

__init__(mapping, delimiter='/')
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

PackageLoader Class

Next topic