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

Possibility to run a script while cookiecutting? #1652

Closed
frankhuurman opened this issue Mar 9, 2022 · 2 comments
Closed

Possibility to run a script while cookiecutting? #1652

frankhuurman opened this issue Mar 9, 2022 · 2 comments

Comments

@frankhuurman
Copy link

  • Cookiecutter version: 1.7.3
  • Template project url: -
  • Python version: 3.8.10
  • Operating System: Ubuntu 20.04 x64

Description:

More of a question rather than an issue:
I've worked with both pre_gen and post_gen hooks which are great. But I really want some way to run a custom script to set some cookiecutter variables while generating the cookiecutter project.

For example I've made a script that pulls the person's name from the system's global git config file and would love to have that data injected into the cookiecutter.json so that I can use cookiecutter._git_user to set it somewhere in the rest of the project(a README in my case).
Now this script doesn't work of course because you can't access the cookiecutter.json with the pre_gen or post_gen hooks.

Is it possible to get this working some way?
All I can think of so far is to generate the README.md manually in the post_gen hook and add the username this way.

@dokempf
Copy link

dokempf commented Mar 16, 2022

This will be covered once #1240 is merged. You will be able to package your custom logic into a local Jinja extension and access it from all your templates.

@frankhuurman
Copy link
Author

Thanks for the reply, I saw it has been merged but there wasn't a new release yet(or usage docs).
Hope it gets released soon!

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