-
Hello, at https://www.adevinta.com we're evaluating We want to share templates among projects having a base template, so we want to ask the questions once and the answers will be shared by the other templates.
We've read a similar question at #402 but according to the doc https://copier.readthedocs.io/en/latest/configuring/#applying-multiple-templates-to-the-same-subproject in order to use multi-template, each template should have its own answers file. We were able to do the trick by "sharing" the answers file generated by the base template, but not sure if this is the right approach. Is it possible this kind of multi-project ? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Glad to hear that, I hope you like it 😊
Yes, that's right. One thing is applying multiple templates to the same project, and a different topic is template inheritance. Right now, Copier only supports obtaining answers from a single file, or from arguments. Also, the answers file is attached to a template, to be able to support autoupdates. So, the 1st thing you should ask yourself is if your templates are related, or if they can be detached. If they can be detached, then put each specific question in the proper template, and evolve them separately. Next, ask yourself if your templates will support updates. If they are bootstrap-only (like Cookiecutter), then you don't really need to have an answers file, because the template will never actually reuse those answers. If you find out that none of these approaches solves your problem, then another resource you can use is to include other yaml files in the main Another option is to use tasks to always propagate answers from the main template to the other used templates. That's custom code, of course. Finally, if none of these work for you, then you're asking for a feature Copier doesn't have right now. If you feel like volunteering a PR, we can discuss the design.
I'm not sure that will work reliably. Possibly, when updating, the new template will override the answers file. In any case, it's not a supported use case. |
Beta Was this translation helpful? Give feedback.
Glad to hear that, I hope you like it 😊
Yes, that's right.
One thing is applying multiple templates to the same project, and a different topic is template inheritance.
Right now, Copier only supports obtaining answers from a single file, or from arguments. Also, the answers file is attached to a template, to be able to support autoupd…