-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Boolean in data-file #1951
Comments
Try moving the extension outside of the tag:
|
Na, same thing. even with the .jinja on the outside, it still generates the file. I have tried the value |
I cannot reproduce the issue you describe: % cd /tmp
% mkdir template
mkdir: created directory 'template'
% echo -e 'include_echo_controller:\n type: bool\n default: false' > template/copier.yml
% echo -e 'hello' > 'template/{% if include_echo_controller %}EchoController.java{% endif %}.jinja'
% ll template
total 8.0K
-rw-r--r-- 1 pawamoy users 54 Jan 28 17:23 copier.yml
-rw-r--r-- 1 pawamoy users 6 Jan 28 17:24 '{% if include_echo_controller %}EchoController.java{% endif %}.jinja'
% copier copy template project
🎤 include_echo_controller (bool)
No
Copying from template version None
create .
% ll project
total 0
% rf project
% copier copy template project
🎤 include_echo_controller (bool)
Yes
Copying from template version None
create .
create EchoController.java |
Yea so only difference is using a data file. So if you create a yaml wiht:
And then
use what you would need to passs, but mainly here passing as a data file is what causes this |
Ah, right, my bad, let me try again 🙂 |
No problem! |
Still cannot reproduce: % ll template
total 8.0K
-rw-r--r-- 1 pawamoy users 55 Jan 28 17:25 copier.yml
-rw-r--r-- 1 pawamoy users 6 Jan 28 17:24 '{% if include_echo_controller %}EchoController.java{% endif %}.jinja'
-rw-r--r-- 1 pawamoy users 0 Jan 28 18:44 readme.md
% cat values.yml
include_echo_controller: false
% copier copy --trust --data-file=values.yml template project
Copying from template version 0.2.0
create readme.md
% ll project
total 0
-rw-r--r-- 1 pawamoy users 0 Jan 28 18:45 readme.md
% vim values.yml
% cat values.yml
include_echo_controller: true
% rf project
% copier copy --trust --data-file=values.yml template project
Copying from template version 0.2.0
create readme.md
create EchoController.java
% ll project
total 4.0K
-rw-r--r-- 1 pawamoy users 6 Jan 28 18:46 EchoController.java
-rw-r--r-- 1 pawamoy users 0 Jan 28 18:46 readme.md I added a |
What version of copier and what system are you on? This is super funky to me... Im going to try out a few different things i guess |
Copier 9.4.1 too, ArchLinux, Python 3.11.7. |
@crenus Have you been able to solve the problem or narrow it down in a reproducible example? |
Describe the problem
Current problem i am facing is the passing of a boolean in a datafile. I have a jinja condition around creating a file, and when its false, it doesnt generate. I am using a data file for "test cases" that the template works. If i pass the value
false
in a data file, the template still creates the file.If I change the template to check for the value of the input, it works but that would break the usage, cause one uses a string while the input should be a boolean if used by cli
Template
{% if include_echo_controller %}EchoController.java.jinja{% endif %}
And the data file just has:
include_echo_controller: false
And in copier.yml
To Reproduce
No response
Logs
Expected behavior
I expect the parser to treat a boolean in a yaml file as such.
Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu
Copier version
copier 9.4.0
Python version
3.14
Installation method
pip+git
Additional context
No response
The text was updated successfully, but these errors were encountered: