FileSystemLoader Class

Inheritance diagram of FileSystemLoader

class FileSystemLoader(searchpath, encoding='utf-8')

Loads templates from the file system. This loader can find templates in folders on the file system and is the preferred way to load them.

The loader takes the path to the templates as string, or if multiple locations are wanted a list of them which is then looked up in the given order:

>>> loader = FileSystemLoader('/path/to/templates')
>>> loader = FileSystemLoader(['/path/to/templates', '/other/path'])

Per default the template encoding is 'utf-8' which can be changed by setting the encoding parameter to something else.


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


has_source_access bool(x) -> bool


class FileSystemLoader

Method details

__init__(searchpath, encoding='utf-8')
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

DictLoader Class

Next topic

FunctionLoader Class