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
In most programming languages, operators are grouped into families having equal precedence. In Jinja2's parser, each operator has its own precedence level. This affects the associativity of some expressions.
For example, in Python and Java, *,/, //, and % all have the same precedence. In Jinja2, these operators have different precedence. This means that a given expression may yield different results from expected when evaluated in a Jinja2 template (see example). Jinja2 should follow the common convention to avoid "gotchas" and unintuitive behavior.
Python's operator precedence is documented here. Java's operator precedence is described here.
Example:
{{ 10 * 1 // 2 }}
Expected result:
5
Actual result:
0
The text was updated successfully, but these errors were encountered:
In most programming languages, operators are grouped into families having equal precedence. In Jinja2's parser, each operator has its own precedence level. This affects the associativity of some expressions.
For example, in Python and Java,
*
,/
,//
, and%
all have the same precedence. In Jinja2, these operators have different precedence. This means that a given expression may yield different results from expected when evaluated in a Jinja2 template (see example). Jinja2 should follow the common convention to avoid "gotchas" and unintuitive behavior.Python's operator precedence is documented here. Java's operator precedence is described here.
Example:
Expected result:
Actual result:
The text was updated successfully, but these errors were encountered: