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
bool to string filter does not work #882
Comments
try |
Yes, |
Because it's not a bug, but simply operator precedence. Without parentheses your code was probably running as |
Coming from the Unix/Linux world where I think it should be |
I disagree, and this would also be a massively breaking change. |
Can we have a warning at least? |
Real-world use-case for this is Ansible templating Java boolean properties: |
That would be more readable as |
More readable, and much clearer what it does |
Well, I see we read it differently and Jinja currently reads it as you do. But the worst part of the above non-working example is it always silently gives I know Python is happy with that but do you think is it a good idea to issue a warning when using |
Also please share your opinion on an |
Anyway, thank you for your quick responses. Have a nice week. |
Ansible can add this. Just like they did with
Haven't tested it, but probably it does fail in Python 3 where such comparisons fail loudly instead of silently succeeding with a somewhat useless result. Jinja does not do type checks, so it just passes the two operands to Python (didn't check the code, probably it calls |
Nice to know, thank you. |
Expected Behavior
Filtering
bool
tostring
should giveTrue
orFalse
respective of the value.Actual Behavior
Filtering
bool
tostring
always givesFalse
.Template Code
Your Environment
The text was updated successfully, but these errors were encountered: