Jump to >

djblets.extensions.loaders

Template loaders for extensions.

class ExtensionOrigin(package, resource, *args, **kwargs)[source]

Bases: django.template.base.Origin

An origin for a template in an extension.

New in version 3.0.

__init__(package, resource, *args, **kwargs)[source]

Initialize the origin.

Parameters
  • package (unicode) – The name of the package providing the template.

  • resource (unicode) – The resource path within the package.

  • *args (tuple) – Positional arguments to pass to the parent.

  • **kwargs (dict) – Keyword arguments to pass to the parent.

class Loader(engine)[source]

Bases: django.template.loaders.base.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[source]
get_contents(origin)[source]

Return the contents of a template.

Parameters

origin (ExtensionOrigin) – The origin of the template.

Returns

The resulting template contents.

Return type

unicode

Raises

TemplateDoesNotExist – The template could not be found.

get_template_sources(template_name)[source]

Load templates from enabled extensions.

Parameters

template_name (unicode) – The name of the template to load.

Yields

ExtensionOrigin – Each possible location for the template.