DictLoader Class

Inheritance diagram of DictLoader

class DictLoader(mapping)

Loads a template from a python dict. It’s passed a dict of unicode strings bound to template names. This loader is useful for unittesting:

>>> loader = DictLoader({'index.html': 'source here'})

Because auto reloading is rarely useful this is disabled per default.

Methods

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

Attributes

has_source_access bool(x) -> bool

Descriptions

class DictLoader

Method details

__init__(mapping)
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

ChoiceLoader Class

Next topic

FileSystemLoader Class