Skip to content

FunctionLoader

Base classes

Name Children Inherits
LoaderMixin
jinjarope.loaders
Loader mixin which allows to OR loaders into a choice loader.
FunctionLoader
jinja2.loaders
A loader that is passed a function which does the loading. The

⋔ Inheritance diagram

graph TD
  97041655213712["loaders.FunctionLoader"]
  97041656291584["loaders.LoaderMixin"]
  128674497047040["builtins.object"]
  97041654415360["loaders.FunctionLoader"]
  97041655470432["loaders.BaseLoader"]
  97041656291584 --> 97041655213712
  128674497047040 --> 97041656291584
  97041654415360 --> 97041655213712
  97041655470432 --> 97041654415360
  128674497047040 --> 97041655470432

🛈 DocStrings

Bases: LoaderMixin, FunctionLoader

A loader for loading templates from a function.

The function takes a template path as parameter and either returns a (text, None, uptodate_fn) tuple or just the text as str.

Source code in src/jinjarope/loaders.py
class FunctionLoader(LoaderMixin, jinja2.FunctionLoader):
    """A loader for loading templates from a function.

    The function takes a template path as parameter and either returns
    a (text, None, uptodate_fn) tuple or just the text as str.
    """

    ID = "function"

    def __repr__(self) -> str:
        return utils.get_repr(self, self.load_func)

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, FunctionLoader):
            return NotImplemented
        return self.load_func == other.load_func

    def __hash__(self) -> int:
        return hash(self.load_func)

:fa-brands-github: Show source on GitHub