-
I'm migrating from cookiecutter and I would like to keep the structure of my template:
With the following github_repo_name:
type: str
default: "package-skeleton"
help: "The name of the GitHub repository"
_subdirectory: "{{ github_repo_name }}" But then I get an error as the yaml of the subdirectory is already transformed when copier look for it in the template:
Is there a workaround ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The template subdirectory name cannot be templated. It's just the root folder of the project that will be generated, and the user always chooses the name of the generated project (
If you have multiple subdirectories though, that a user can choose from, then the question makes sense. The subdirectory names must still not be templated. The question should offer a few choices, and there should be one subdirectory for each choice. Let me know if anything is unclear, I can try to expand 🙂 |
Beta Was this translation helpful? Give feedback.
-
thanks @pawamoy that's very clear. Just to justify a bit more my use case, a more complete copier.yaml file is: project_name:
typr: str
default: "Package skeleton"
help: "The name of the project"
github_repo_name:
type: str
default: "{{ project_name.lower().replace(' ', '-') }}"
help: "The name of the GitHub repository"
project_slug:
type: str
default: "{{ github_repo_name.lower().replace('-', '_') }}"
help: "The slug that will be used to name the lib package" allowing the user to fill only the Project name (with space accents and everything) and the template is extracting both the slug and github repo (reused in multiple places afterward like pyproject.toml, doc conf.py etc...). In what I was doing the user fill it once and for all and propagate to github. From what I understand from your answer, he will need to fill it in the command line as well upfront ? |
Beta Was this translation helpful? Give feedback.
The template subdirectory name cannot be templated. It's just the root folder of the project that will be generated, and the user always chooses the name of the generated project (
copier copy template user_chosen_name
). So my recommendation is to:project
for example)github_repo_name
question from copier.yml (or use it for something else)If you have multiple subdirectories though, that a user can choose from, then the question makes sense. The subdirectory names must still not be templated. The question should offer a few choices, and there should be one subdirectory for each choice.
Let me know if anything is unclear, I can…