Skip to content

Where to put Jinja extension code? #1211

@ghost

Description

Hi
I put extension code in cookiecutter.json

{
"_extensions": ["super.SuperExtension"]
}

and I created the super/super.py and super/__init__.py files with:

from jinja2 import nodes
from jinja2.ext import Extension


class SuperExtension(Extension):
    # a set of names that trigger the extension.
    # tags = {'cache'}

    def __init__(self, environment):
        super(SuperExtension, self).__init__(environment)

        # add the defaults to the environment
        environment.extend(
            keep_trailing_newline=True
        )

However when I run the cookiecutter command it keeps telling me
cookiecutter.exceptions.UnknownExtension: Unable to load extension: No module named 'super'

I copied the super directory everywhere I can think and it don't find it.
So my question is where do I need to put the super dir?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions