Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change jinja2 variable_start_string and variable_end_string, NonTemplatedInputDirException #1966

Open
sacha-c opened this issue Oct 23, 2023 · 2 comments

Comments

@sacha-c
Copy link
Contributor

sacha-c commented Oct 23, 2023

  • Cookiecutter version: 2.4.0
  • Template project url: N/A
  • Python version: 3.10.9
  • Operating System: MacOS

Description:

Overriding jinja's variable_start_string and variable_end_string when using _jinja2_env_vars in cookiecutter.json gives an error NonTemplatedInputDirException.

The reason is that the variable start & end strings are hardcoded when cookiecutter is looking for the template directory (see here). This means that cookiecutter always looks for {{ and }} when looking for a template directory, which should actually be variable_start/end_string in the case of overriding them.

This is the same behavior as this closed issue #1736 in which the root problem was not resolved.

I have made a PR addressing this issue, and am very open to feedback #1963

What I've run:

cookiecutter .

in a project with cookiecutter.json

    ...,
    "_jinja2_env_vars": {
        "variable_start_string": "{%{",
        "variable_end_string": "}%}"
    }
@sacha-c
Copy link
Contributor Author

sacha-c commented Nov 7, 2023

I have updated my PR with an additional fix regarding the usage of these placeholders.

Looking forward to your feedback 🙂

@codytodonnell
Copy link

I'm running into this same issue. It would be very useful for using cookiecutter with React projects where {{ can possibly show up in many places. Thanks @sacha-c for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants