You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, in rinja a condition is considered to match if it evaluates to true or a reference to true. That's a sensible and kinda obvious implementation.
In Jinja, Handlebars, etc. the pythonic concept of "truthiness" is used instead: https://realpython.com/python-boolean/. Everything that could be considered falsy, empty or nullish (0, None, "", [], false) will result in a missed condition.
I think that this behavior is very useful in a templating language. What do you think? Should rinja adopt that concept, too? It would not affect anyone who doesn't (want to) use it. You can write {% if !s.is_empty(), but with this change you could simply write {% if s to get the same result.
The text was updated successfully, but these errors were encountered:
I'm shared on this: I love to have things explicit when reading the code. So forcing users to write {% if x != 0 %} instead of {% if x %} is better from this point of view.
But it's also a templating language, so maybe that's what users expect... I'm more on "explicit code" side. ^^'
Right now, in rinja a condition is considered to match if it evaluates to
true
or a reference totrue
. That's a sensible and kinda obvious implementation.In Jinja, Handlebars, etc. the pythonic concept of "truthiness" is used instead: https://realpython.com/python-boolean/. Everything that could be considered falsy, empty or nullish (
0
,None
,""
,[]
,false
) will result in a missed condition.I think that this behavior is very useful in a templating language. What do you think? Should rinja adopt that concept, too? It would not affect anyone who doesn't (want to) use it. You can write
{% if !s.is_empty()
, but with this change you could simply write{% if s
to get the same result.The text was updated successfully, but these errors were encountered: