Skip to content

templates ¤

The subpackage containing the builtin templates.

Functions:

configure_env ¤

configure_env(env: Environment) -> None

Configure the Jinja environment.

Parameters:

  • env (Environment) –

    The environment to configure.

Source code in src/git_changelog/templates/__init__.py
18
19
20
21
22
23
24
def configure_env(env: Environment) -> None:
    """Configure the Jinja environment.

    Parameters:
        env: The environment to configure.
    """
    env.filters.update({"is_url": _filter_is_url})

get_custom_template ¤

get_custom_template(path: str | Path) -> Template

Get a custom template instance.

Parameters:

  • path (str | Path) –

    Path to the custom template.

Returns:

  • Template

    The Jinja template.

Source code in src/git_changelog/templates/__init__.py
27
28
29
30
31
32
33
34
35
36
def get_custom_template(path: str | Path) -> Template:
    """Get a custom template instance.

    Arguments:
        path: Path to the custom template.

    Returns:
        The Jinja template.
    """
    return JINJA_ENV.from_string(Path(path).read_text())

get_template ¤

get_template(name: str) -> Template

Get a builtin template instance.

Parameters:

  • name (str) –

    The template name.

Returns:

  • Template

    The Jinja template.

Source code in src/git_changelog/templates/__init__.py
39
40
41
42
43
44
45
46
47
48
def get_template(name: str) -> Template:
    """Get a builtin template instance.

    Arguments:
        name: The template name.

    Returns:
        The Jinja template.
    """
    return JINJA_ENV.from_string(TEMPLATES_PATH.joinpath(f"{name}.md.jinja").read_text())