_copier_conf
and other global variables can't be used in the questions section
#1502
Labels
Milestone
_copier_conf
and other global variables can't be used in the questions section
#1502
Describe the problem
The
_copier_conf
variable can be used in templated file names, file contents, and task and migration commands, however it can't be used in the questions section, for example in thedefault
orwhen
key of a template.I don't know if this is intentional design or an oversight. From my point of view it is definitely unexpected.
Supporting this would enable some new use cases. In my case I want to add a new boolean question to a project, that defaults no yes for new projects, but defaults to no for existing projects being updated.
I tried doing this by setting
default: "{{ _copier_conf.src_path is not none }}"
This resulted in
'_copier_conf' is undefined
Template
To Reproduce
No response
Logs
No response
Expected behavior
The question should default to yes for new projects and no for existing projects
Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
Sonoma 14.2.1
Copier version
9.1.1
Python version
Python 3.11.0
Installation method
distro package
Additional context
I can try writing a pull request for this. Doesn't look too hard to fix.
The text was updated successfully, but these errors were encountered: