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
  94173637976672["loaders.DictLoader"]
  94173637890544["loaders.LoaderMixin"]
  139866058043616["builtins.object"]
  94173637388560["loaders.DictLoader"]
  94173636407456["loaders.BaseLoader"]
  94173637890544 --> 94173637976672
  139866058043616 --> 94173637890544
  94173637388560 --> 94173637976672
  94173636407456 --> 94173637388560
  139866058043616 --> 94173636407456

🛈 DocStrings

Bases: LoaderMixin, DictLoader

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

Source code in src/jinjarope/loaders.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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