loaders.django

Provide wrappers for the standard template loaders to adapt them for use by the static engine. These loaders should be used instead of the standard ones, even though some are just renamed. This will allow app user code to be updated transparently if these loaders need to be adapted to work with Django Static Templates in the future.

class render_static.loaders.django.StaticAppDirectoriesLoader[source]

Bases: DirectorySupport, Loader

Extension of django.template.loaders.app_directories.Loader

Searches application directories based on the engine’s configured app directory name. This loader extends the standard AppDirLoader to provide an extended Origin type that contains the AppConfig of the app where the template was found. This information may be used later to determine where the template should be rendered to disk.

__init__(engine, dirs=None)
classmethod __new__(*args, **kwargs)
class render_static.loaders.django.StaticFilesystemLoader[source]

Bases: DirectorySupport

Simple extension of django.template.loaders.filesystem.Loader

__init__(engine, dirs=None)
classmethod __new__(*args, **kwargs)
class render_static.loaders.django.StaticAppDirectoriesBatchLoader[source]

Bases: StaticAppDirectoriesLoader, BatchLoaderMixin

A loader that enables glob pattern selectors to load batches of templates from app directories.

Yields batches of template names in order of preference, where preference is defined by the precedence of Django apps.

__init__(engine, dirs=None)
classmethod __new__(*args, **kwargs)
class render_static.loaders.django.StaticFilesystemBatchLoader[source]

Bases: StaticFilesystemLoader, BatchLoaderMixin

A loader that enables glob pattern selectors to load batches of templates from the file system.

Yields batches of template names in order of preference, where preference is defined by the order directories are listed in.

__init__(engine, dirs=None)
classmethod __new__(*args, **kwargs)
class render_static.loaders.django.StaticLocMemLoader[source]

Bases: Loader

Simple extension of django.template.loaders.locmem.Loader

__init__(engine, templates_dict)
classmethod __new__(*args, **kwargs)

loaders.jinja2

Subclass the Jinja2 loaders. It is recommended that even for loaders that are simple empty subclasses of the Jinja2 loaders, that these static redefinitions be used for static template engines insteead. If in the future, changes to these loaders need to be made to keep code working with renderstatic that will be transparent to users.

Jinja2 Loaders

class render_static.loaders.jinja2.SearchableLoader[source]

Bases: BaseLoader

Loaders should implement this protocol to support shell tab-completion.

__init__()
classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticFileSystemLoader[source]

Bases: SearchableLoader, FileSystemLoader

We adapt the base loader to support loading directories as templates.

__init__(searchpath, encoding='utf-8', followlinks=False)
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticFileSystemBatchLoader[source]

Bases: StaticFileSystemLoader, BatchLoaderMixin

This loader extends the basic StaticFileSystemLoader to work with batch selectors. Use this loader if you want to be able to use wildcards to load Jinja2 templates.

Note

This is the default loader used for the Jinja2 backend if no loader is specified.

__init__(searchpath, encoding='utf-8', followlinks=False)
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticPackageLoader[source]

Bases: SearchableLoader, PackageLoader

__init__(package_name, package_path='templates', encoding='utf-8')
Parameters:
  • package_name (str)

  • package_path (str)

  • encoding (str)

Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticPrefixLoader[source]

Bases: SearchableLoader, PrefixLoader

__init__(mapping, delimiter='/')
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticFunctionLoader[source]

Bases: FunctionLoader

__init__(load_func)
Parameters:

load_func (Callable[[str], str | Tuple[str, str | None, Callable[[], bool] | None] | None])

Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticDictLoader[source]

Bases: SearchableLoader, DictLoader

__init__(mapping)
Parameters:

mapping (Mapping[str, str])

Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticChoiceLoader[source]

Bases: SearchableLoader, ChoiceLoader

__init__(loaders)
Parameters:

loaders (Sequence[BaseLoader])

Return type:

None

classmethod __new__(*args, **kwargs)
class render_static.loaders.jinja2.StaticModuleLoader[source]

Bases: ModuleLoader

__init__(path)
Parameters:

path (str | PathLike[str] | Sequence[str | PathLike[str]])

Return type:

None

classmethod __new__(*args, **kwargs)

loaders.mixins

Helper classes for augmenting loader behavior.

class render_static.loaders.mixins.BatchLoaderMixin[source]

Bases: object

A mixin for Jinja2 loaders that enables glob pattern selectors to load batches of templates from the file system.

Yields batches of template names in order of preference, where preference is defined by the order directories are listed in.

__init__()
classmethod __new__(*args, **kwargs)