j2cli
j2cli copied to clipboard
if conditional with environment variable is always true unless blank
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