copier-org / copier

Library and command-line utility for rendering projects templates.
https://readthedocs.org/projects/copier/
MIT License
2.01k stars 181 forks source link

Support advanced inclusion of other YAML files #1076

Open nicolas-g opened 1 year ago

nicolas-g commented 1 year ago

Is your feature request related to a problem? Please describe.

Using too many conditionals in the copier.yml questionnaire file can make it lengthy and difficult to manage. To make the file more organized and user-friendly, we can use the include feature to split the main copier.yml file into separate ones. However, it would be even better if variables or conditionals can also be utilized when using include statements.

Describe the solution you'd like

A conditional to be used "when" a file is to be included will be nice:

!include env/dev.yml
when: "{{ env_type == 'dev' }}"

or use a variable while you use the include statement:

!include env/{{ env_type }}.yml

Describe alternatives you've considered The above doesn't seem to be supported and result in a failure.

Additional context NA

edumargra commented 3 months ago

Hi, We just encountered the same issue and I would like to make it work. It's in "comunity contribution", so maybe I should only commented when a working prototype is done, but just letting you know.