Skip to content

template_loader_mixin

TemplateLoaderMixin

A Mixin to load Jinja Templates.

Source code in src/cloe_nessy/models/mixins/template_loader_mixin.py
class TemplateLoaderMixin:
    """A Mixin to load Jinja Templates."""

    @staticmethod
    def get_template(template_path: Path, template_name: str) -> JinjaTemplate:
        """Load the specified template."""
        loader: FileSystemLoader = FileSystemLoader(template_path)

        env = Environment(loader=loader, keep_trailing_newline=True)

        return env.get_template(template_name)

get_template(template_path, template_name) staticmethod

Load the specified template.

Source code in src/cloe_nessy/models/mixins/template_loader_mixin.py
@staticmethod
def get_template(template_path: Path, template_name: str) -> JinjaTemplate:
    """Load the specified template."""
    loader: FileSystemLoader = FileSystemLoader(template_path)

    env = Environment(loader=loader, keep_trailing_newline=True)

    return env.get_template(template_name)