Skip to content

Support nested config files#1770

Merged
ericof merged 8 commits intocookiecutter:mainfrom
dariocurr:master
Jun 13, 2023
Merged

Support nested config files#1770
ericof merged 8 commits intocookiecutter:mainfrom
dariocurr:master

Conversation

@dariocurr
Copy link
Copy Markdown
Contributor

If you wish to create a hierarchy of templates and use cookiecutter to choose among them,
you need just to specify the key template in the main configuration file to reach
the other ones.

Let's imagine to have the following structure:

main-directory/
├── project-1
│   ├── cookiecutter.json
│   ├── {{cookiecutter.project_slug}}
|	│   ├── ...
├── project-2
│   ├── cookiecutter.json
│   ├── {{cookiecutter.project_slug}}
|	│   ├── ...
└── cookiecutter.json

It is possible to specify in the main cookiecutter.json how to reach the other
config files as follows:

{
    "template": [
	"Project 1 (./project-1)",
	"Project 2 (./project-2)"
    ]
}

Then, when cookiecutter is launched in the main directory it will ask to choice
among the possible templates:

Select template:
1 - Project 1 (./project-1)
2 - Project 2 (./project-2)
Choose from 1, 2 [1]:

Once a template is chosen, for example 1, it will continue to ask the info required by
cookiecutter.json in the project-1 folder, such as project-slug

@dariocurr
Copy link
Copy Markdown
Contributor Author

Any news?

@drkeoni
Copy link
Copy Markdown

drkeoni commented Oct 20, 2022

FWIW my organization would use this if this MR can be merged in.

@dariocurr
Copy link
Copy Markdown
Contributor Author

dariocurr commented Oct 21, 2022

FWIW my organization would use this if this MR can be merged in.

Seems like no one from the team cares about this PR

@cookiecutter cookiecutter deleted a comment from liortct Jun 13, 2023
@ericof ericof self-requested a review June 13, 2023 02:45
@ericof ericof added enhancement This issue/PR relates to a feature request. feature This issue/PR relates to major feature request. labels Jun 13, 2023
@ericof ericof changed the title Allow nested config files Support nested config files Jun 13, 2023
Copy link
Copy Markdown
Member

@ericof ericof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @dariocurr, and sorry for the long time it took us to review your PR.

@ericof ericof merged commit 7e4442b into cookiecutter:main Jun 13, 2023
@dariocurr
Copy link
Copy Markdown
Contributor Author

Thank you

@mhsmith
Copy link
Copy Markdown

mhsmith commented Jul 7, 2023

This was a breaking change for users who already used the template key for something else (beeware/briefcase#1347), but it was not released with a major version number increment.

Perhaps it would be better for special keywords to be prefixed with cookiecutter_ to avoid clashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This issue/PR relates to a feature request. feature This issue/PR relates to major feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants