Opened 13 years ago
Closed 13 years ago
#17383 closed Cleanup/optimization (wontfix)
template filter arguments don't tolerate whitespace
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This generates an error:
{{ today|date: "SHORT_DATE_FORMAT" }}
but this doesn't:
{{ today|date:"SHORT_DATE_FORMAT" }}
Since there is a colon ending the filter name and a quote beginning the argument, it seems like the whitespace could be ignored. This would make the template easier to read and use, which is especially important in the templates since this is where non-programmers are most likely to be contributing.
Note:
See TracTickets
for help on using tickets.
I understand your proposal but I think it makes chained filters harder to read:
{{ var|cook: "spam"|fry: "eggs" }}
.Also, for the sake of consistency throughout the Django ecosystem, it's better to have only one syntax, and the current one is good enough.
I believe a project like Django has to make these aesthetic choices early, and then stick with them. In other words, when you build the nuclear plant, you're allowed to chose the color of the bike shed :)