j2cli icon indicating copy to clipboard operation
j2cli copied to clipboard

if conditional with environment variable is always true unless blank

Open kylegibson opened this issue 2 years ago • 0 comments

I discovered that if you want a true/false with a environment variable, the only combination that matters is whether the value is set or not:

foo.env:

test_1=false
test_2=False
test_3=1
test_4=

test.sh:

{% if test_1 %}echo 1{% endif %}
{% if test_2 %}echo 2{% endif %}
{% if test_3 %}echo 3{% endif %}
{% if test_4 %}echo 4{% endif %}

Result:

$ j2 test.sh foo.env
echo 1
echo 2
echo 3

kylegibson avatar Nov 28 '22 11:11 kylegibson