Copier Template Extensions

0.3.3 · active · verified Fri Apr 17

Copier Template Extensions (copier-template-extensions) is a specialized Jinja2 extension for Copier, enabling the loading of other Jinja2 extensions using file paths relative to the template root, rather than standard Python dotted paths. As of version 0.3.3, it offers improved migration support. The project maintains an active release cadence with periodic updates.

Common errors

Warnings

Install

Imports

Quickstart

To enable `copier-template-extensions`, include its module path in the `_extensions` list within your `copier.yaml`. This allows Copier to load other Jinja2 extensions specified by relative file paths within your template, such as `my_template_utils.py` shown here. The example demonstrates a custom filter named `custom_filter`.

# copier.yaml
_extensions:
  - "copier_template_extensions.CopierExtension"
  # You can now load other extensions using relative paths:
  - "./my_template_utils.py:custom_filter"

# my_template_utils.py
def custom_filter(value):
    return f"CUSTOM({value.upper()})"

# template.txt.jinja
Hello {{ 'world' | custom_filter }}

view raw JSON →