#10689 closed (invalid)
boolean expressions in the template system's if clause
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.0 |
Severity: | Keywords: | if boolean and or binding | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
"if tags don't allow and and or clauses within the same tag, because the order of logic would be ambiguous."
Thats not true, "or" binds stronger.
Change History (3)
comment:1 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
follow-up: 3 comment:2 by , 16 years ago
Sorry, actually i was wrong, "and" binds stronger, if you dont believe me you can look it up yourself: docs.python.org/reference/expressions.html#summary
Anyway: the order of logic is *not* ambiguous and disallowing expressions with and/or combinations for this reason is majorly wrong.
comment:3 by , 16 years ago
Replying to anonymous:
Sorry, actually i was wrong, "and" binds stronger, if you dont believe me you can look it up yourself: docs.python.org/reference/expressions.html#summary
Anyway: the order of logic is *not* ambiguous and disallowing expressions with and/or combinations for this reason is majorly wrong.
The fact that you got it wrong in the initial description rather proves the point Russell mentioned. A non-programmer template designer isn't likely to know intuitively which binds more strongly, even a programmer may have to look it up. Sure, technically the "ambiguity" is defined away by the language specifying the precedence, but the point is expressions involving combined ands and ors are likely ambiguous to the general intended audience of template readers/writers, therefore such expressions are not allowed. You may disagree with the "understandable to non-programmers" goal of Django templates, but you cannot, after getting the precedence wrong yourself, logically argue that this design decision doesn't help achieve that goal.
The template language is designed to be usable by people that don't necessarily have a programming background. Parsing complex boolean expressions isn't a common skill outside of the world of programmers, so in order to keep the template language clear and unambiguous, we don't allow combination of expressions.