Skip to content

DictLoader

Base classes

Name Children Inherits
LoaderMixin
jinjarope.loaders
Loader mixin which allows to OR loaders into a choice loader.
DictLoader
jinja2.loaders
Loads a template from a Python dict mapping template names to

⋔ Inheritance diagram

graph TD
  94892546039504["loaders.DictLoader"]
  94892548325824["loaders.LoaderMixin"]
  140247609577664["builtins.object"]
  94892544497424["loaders.DictLoader"]
  94892544482432["loaders.BaseLoader"]
  94892548325824 --> 94892546039504
  140247609577664 --> 94892548325824
  94892544497424 --> 94892546039504
  94892544482432 --> 94892544497424
  140247609577664 --> 94892544482432

🛈 DocStrings

Bases: LoaderMixin, DictLoader

A loader to load static content from a path->template-str mapping.

Source code in src/jinjarope/loaders.py
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
class DictLoader(LoaderMixin, jinja2.DictLoader):
    """A loader to load static content from a path->template-str mapping."""

    ID = "dict"

    def __repr__(self):
        return utils.get_repr(self, mapping=self.mapping)

    def __add__(self, other: dict[str, str] | jinja2.DictLoader) -> DictLoader:
        if isinstance(other, jinja2.DictLoader):
            mapping = {**self.mapping, **other.mapping}
        else:
            mapping = {**self.mapping, **other}
        return DictLoader(mapping)

    def __eq__(self, other):
        return type(self) is type(other) and self.mapping == other.mapping

    def __hash__(self):
        return hash(tuple(sorted(self.mapping.items())))

Show source on GitHub