jinja2.PackageLoader

class jinja2.PackageLoader(package_name, package_path='templates', encoding='utf-8')[source]

Load templates from python eggs or packages. It is constructed with the name of the python package and the path to the templates in that package:

loader = PackageLoader('mypackage', 'views')

If the package path is not given, 'templates' is assumed.

Per default the template encoding is 'utf-8' which can be changed by setting the encoding parameter to something else. Due to the nature of eggs it’s only possible to reload templates if the package was loaded from the file system and not a zip file.

Methods

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

Attributes

has_source_access