djblets.extensions.loaders¶
Template loaders for extensions.
- class ExtensionOrigin(package, resource, *args, **kwargs)¶
Bases:
Origin
An origin for a template in an extension.
New in version 3.0.
- __init__(package, resource, *args, **kwargs)¶
Initialize the origin.
- class Loader(engine)¶
Bases:
Loader
Loads templates found within an extension.
This will look through all enabled extensions and attempt to fetch the named template under the
templates
directory within the extension’s package.This should be added last to the list of template loaders.
New in version 0.9.
- is_usable = True¶
- get_contents(origin)¶
Return the contents of a template.
- Parameters:
origin (
ExtensionOrigin
) – The origin of the template.- Returns:
The resulting template contents.
- Return type:
- Raises:
TemplateDoesNotExist – The template could not be found.
- get_template_sources(template_name)¶
Load templates from enabled extensions.
- Parameters:
template_name (
unicode
) – The name of the template to load.- Yields:
ExtensionOrigin
– Each possible location for the template.