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
  94587532077584["loaders.DictLoader"]
  94587531523792["loaders.LoaderMixin"]
  139903737475296["builtins.object"]
  94587530761120["loaders.DictLoader"]
  94587533553392["loaders.BaseLoader"]
  94587531523792 --> 94587532077584
  139903737475296 --> 94587531523792
  94587530761120 --> 94587532077584
  94587533553392 --> 94587530761120
  139903737475296 --> 94587533553392

🛈 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