Last active
December 13, 2015 21:09
-
-
Save tomoemon/4975511 to your computer and use it in GitHub Desktop.
jinja2 strange operator priority
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2 import Environment | |
env = Environment() | |
env.from_string("{% if x is sameas 100 and 1 %}xxx{% else %}yyy{% endif %}").render({"x": 100}) | |
# => yyy | |
env.from_string("{% if (x is sameas 100) and 1 %}xxx{% else %}yyy{% endif %}").render({"x": 100}) | |
# => xxx (expected) | |
env.from_string("{% if x is sameas (100 and 1) %}xxx{% else %}yyy{% endif %}").render({"x": 100}) | |
# => yyy (actual) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jinja2 Documentation about Builtin Tests
http://jinja.pocoo.org/docs/templates/#list-of-builtin-tests