Skip to content

FileSystemLoader

Base classes

Name Children Inherits
LoaderMixin
jinjarope.loaders
Loader mixin which allows to OR loaders into a choice loader.
FileSystemLoader
jinja2.loaders
Load templates from a directory in the file system.

⋔ Inheritance diagram

graph TD
  97041655008080["loaders.FileSystemLoader"]
  97041656291584["loaders.LoaderMixin"]
  128674497047040["builtins.object"]
  97041655094064["loaders.FileSystemLoader"]
  97041655470432["loaders.BaseLoader"]
  97041656291584 --> 97041655008080
  128674497047040 --> 97041656291584
  97041655094064 --> 97041655008080
  97041655470432 --> 97041655094064
  128674497047040 --> 97041655470432

🛈 DocStrings

Bases: LoaderMixin, FileSystemLoader

A loader to load templates from the file system.

Source code in src/jinjarope/loaders.py
class FileSystemLoader(LoaderMixin, jinja2.FileSystemLoader):
    """A loader to load templates from the file system."""

    ID = "filesystem"

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

    def __add__(self, other: FileSystemLoader | str | os.PathLike[str]) -> FileSystemLoader:
        ls = [other] if isinstance(other, str | os.PathLike) else other.searchpath
        return FileSystemLoader([*self.searchpath, *ls])  # pyright: ignore

    def __bool__(self) -> bool:
        return len(self.searchpath) > 0

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

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

:fa-brands-github: Show source on GitHub