Comparisons in jinja don't behave like comparisons in Python.
template = '''{{4 < 2 < 3}}
{{a < b < c}}'''
t = Template(template)
print(t.render(a = 4, b = 2, c = 3))
Expected output:
Output:
Python code:
Output: False
The problem lies in
|
try: |
|
for op in self.ops: |
|
new_value = op.expr.as_const(eval_ctx) |
|
result = _cmpop_to_func[op.op](value, new_value) |
|
value = new_value |
|
except Exception: |
where the result of the comparison depends only on the final operator result.
I would like to submit a PR for this.
- Python version: 3.6.7
- Jinja version: 2.10
Comparisons in jinja don't behave like comparisons in Python.
Expected output:
Output:
Python code:
Output:
FalseThe problem lies in
jinja/jinja2/nodes.py
Lines 775 to 780 in 1af1205
where the result of the comparison depends only on the final operator result.
I would like to submit a PR for this.