Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional expression not working properly #1801

Open
me-kell opened this issue Dec 4, 2022 · 0 comments
Open

Conditional expression not working properly #1801

me-kell opened this issue Dec 4, 2022 · 0 comments

Comments

@me-kell
Copy link

me-kell commented Dec 4, 2022

  • Cookiecutter: 2.2.1
  • Python version: 3.9.2
  • Operating System: both on linux and on windows

Description:

I'd expect the conditional {% if cookiecutter.var %} not to be true if the cookiecutter.var is false.

But {% if cookiecutter.var %} produces output no matter if var=False or var=True

What I've run:

$ python3 -m venv /path/to/dir
$ cd /path/to/dir
$ bin/pip install cookiecutter==2.1.1
$ rm -rf mycookiecutter
$ mkdir mycookiecutter
$ mkdir mycookiecutter/\{\{\ cookiecutter.target\ \}\}
$ cat <<'EOF' | tee mycookiecutter/cookiecutter.json
> {
>   "target": "test",
>   "var": false
> }
> EOF

$ cat <<'EOF' | tee mycookiecutter/\{\{\ cookiecutter.target\ \}\}/output
> {% if cookiecutter.var %}
>   conditional expression is true. var is {{ cookiecutter.var }}
> {% else %}
>   conditional expression is false. var is {{ cookiecutter.var }}
> {% endif %}
> EOF

Calling bin/cookiecutter -f mycookiecutter either with var=False or var=True the result is the same

$ bin/cookiecutter -f mycookiecutter && cat test/output
target [test]: 
var [False]: 

  conditional expression is true. var is False

$ bin/cookiecutter -f mycookiecutter && cat test/output
target [test]: 
var [False]: True

  conditional expression is true. var is True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant