Open wolfendale opened 4 years ago
@wolfendale Following up on some of our investigations, I've looked at the javascript nunjucks implementation and found the following so far:
filters have higher precedence than power, eg for {{ 2 ** -5 | abs }}
the result is 32
instead of 0.03125
filters have lower precedence than expressions with unary modifiers -
and +
-
: eg for {{ -5.5 | round }}
the result is -5
instead of -6
+
: eg for {{ +true | float }}
the result is 1
and for {{ +(true | float) }}
the result is NaN
Open for investigation still:
not
is unclear
{{ false | default("foo", true) }} // foo
{{ not false | default("foo", true) }} // false
{{ not (false | default("foo", true)) }} // false
{{ true | default("foo", true) }} // true
{{ not true | default("foo", true) }} // false
@amaalali really interesting, currently the we give unary +
, -
and not
equal precedence so that hints at another subtle bug.
In nunjucks:
outputs
2
In this library it outputs
-2
because filter call binds extremely loosely.I'm not sure of the exact precedence it should have, one to experiment with.