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

Hooks don't have access to the original template directory #706

Open
rivol opened this issue May 30, 2016 · 2 comments
Open

Hooks don't have access to the original template directory #706

rivol opened this issue May 30, 2016 · 2 comments

Comments

@rivol
Copy link

rivol commented May 30, 2016

I'm trying to include a configuration summary with the generated projects. The summary would be a JSON file, dumped by post_gen_project hook, which would include the cookiecutter context that was used to create the project (same as the files used by --replay functionality).

But I'd also like the config summary to include the revision (commit hash) of the used cookiecutter template. This is useful for enabling easy upgrading of the used template, i.e. incorporating the template changes into a project that had been generated from an older version of the template.

Problem is that ATM hooks don't seem to have any way of accessing the template source dir (correct me if I'm wrong). I'd propose to modify generate_files() to add some special keys to the context, including (but perhaps not limited to) the original template directory. The new values could either go into a new toplevel dict in the context (next to the cookiecutter dict), or maybe into the existing cookiecutter object, prefixed with underscores.

Let me know if this is something that would fit into cookiecutter. If yes and we agree on the implementation, I should be able to create a PR.

@eviweb
Copy link
Contributor

eviweb commented May 30, 2016

Hi @rivol,
this PR #694 resolves this issue by passing the cookiecutter context serialized in JSON to hooks through the stdin stream.
It also provides an option to run real hooks in place, instead of creating temporary copies.
Please have a look and feel free to give your feedack.

best regards

Eric

@divick
Copy link

divick commented Apr 20, 2017

+1

simobasso added a commit to simobasso/cookiecutter that referenced this issue Jan 2, 2021
implement a templates directory so a maintainer can use `extends`, `includes`,
`blocks`, `import` and `super` inside the cookiecutter project template
using jinja directly.

docs: https://jinja.palletsprojects.com/en/2.11.x/templates/#template-inheritance

closes: cookiecutter#1484
ref: cookiecutter#706
ref: cookiecutter#59
ref: cookiecutter#1004
simobasso added a commit to simobasso/cookiecutter that referenced this issue Jan 2, 2021
implement a templates directory so a maintainer can use `extends`, `includes`,
`blocks`, `import` and `super` inside the cookiecutter project template
using jinja directly.

docs: https://jinja.palletsprojects.com/en/2.11.x/templates/#template-inheritance

closes: cookiecutter#1484
ref: cookiecutter#706
ref: cookiecutter#59
ref: cookiecutter#1004
abvikg pushed a commit to Over-haul/cookiecutter that referenced this issue Jul 16, 2021
implement a templates directory so a maintainer can use `extends`, `includes`,
`blocks`, `import` and `super` inside the cookiecutter project template
using jinja directly.

docs: https://jinja.palletsprojects.com/en/2.11.x/templates/#template-inheritance

closes: cookiecutter#1484
ref: cookiecutter#706
ref: cookiecutter#59
ref: cookiecutter#1004
insspb pushed a commit to simobasso/cookiecutter that referenced this issue Jun 6, 2022
implement a templates directory so a maintainer can use `extends`, `includes`,
`blocks`, `import` and `super` inside the cookiecutter project template
using jinja directly.

docs: https://jinja.palletsprojects.com/en/2.11.x/templates/#template-inheritance

closes: cookiecutter#1484
ref: cookiecutter#706
ref: cookiecutter#59
ref: cookiecutter#1004
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

Successfully merging a pull request may close this issue.

3 participants