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,LoaderExtension of
django.template.loaders.app_directories.LoaderSearches 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:
DirectorySupportSimple extension of
django.template.loaders.filesystem.Loader- __init__(engine, dirs=None)¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.django.StaticAppDirectoriesBatchLoader[source]¶
Bases:
StaticAppDirectoriesLoader,BatchLoaderMixinA 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,BatchLoaderMixinA 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)¶
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.
- class render_static.loaders.jinja2.SearchableLoader[source]¶
Bases:
BaseLoaderLoaders should implement this protocol to support shell tab-completion.
- __init__()¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticFileSystemLoader[source]¶
Bases:
SearchableLoader,FileSystemLoaderWe adapt the base loader to support loading directories as templates.
- __init__(searchpath, encoding='utf-8', followlinks=False)¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticFileSystemBatchLoader[source]¶
Bases:
StaticFileSystemLoader,BatchLoaderMixinThis 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)¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticPackageLoader[source]¶
Bases:
SearchableLoader,PackageLoader- __init__(package_name, package_path='templates', encoding='utf-8')¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticPrefixLoader[source]¶
Bases:
SearchableLoader,PrefixLoader- __init__(mapping, delimiter='/')¶
- Parameters:
mapping (Mapping[str, BaseLoader])
delimiter (str)
- Return type:
None
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticFunctionLoader[source]¶
Bases:
FunctionLoader- __init__(load_func)¶
- classmethod __new__(*args, **kwargs)¶
- class render_static.loaders.jinja2.StaticDictLoader[source]¶
Bases:
SearchableLoader,DictLoader- 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)¶
loaders.mixins¶
Helper classes for augmenting loader behavior.
- class render_static.loaders.mixins.BatchLoaderMixin[source]¶
Bases:
objectA 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)¶