Replies: 3 comments 18 replies
-
|
You could use my extension, https://github.com/pawamoy/copier-templates-extensions, particularly the Context Hook extension, to augment your context (in this case adding the |
Beta Was this translation helpful? Give feedback.
-
|
You can use a jinja macro. Macros can be defined in one file and then imported in others. And allow you to reuse partial templates. It would fit your use case exactly AFAICS. Example:
|
Beta Was this translation helpful? Give feedback.
-
|
If you want to avoid importing the macro definitions, you can define that pattern in a file and include it instead. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my particular case I have the following copier.yml:
And in various parts of my .jinja files I do the following:
"Changelog" = "https://github.com/{{ github_user }}/{{ github_repo }}/releases""Bug Tracker" = "https://github.com/{{ github_user }}/{{ github_repo }}/issues""Issues" = "https://github.com/{{ github_user }}/{{ github_repo }}/issues""Discussions" = "https://github.com/{{ github_user }}/{{ github_repo }}/discussions"I want to define a variable in copier.yml that is the same as "questions":
And then use:
"Changelog" = "{{ repository }}/releases""Bug Tracker" = "{{ repository }}/issues""Issues" = "{{ repository }}/issues""Discussions" = "{{ repository }}/discussions"Can this be done in copier?
Beta Was this translation helpful? Give feedback.
All reactions