Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

comment:2 follow-up: Changed 5 years ago by 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.

comment:3 in reply to: ↑ 2 Changed 5 years ago by kmtracey

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.