Opened 17 years ago

Last modified 15 years ago

#5971 closed

django.template.TokenParser inconsistent with parsing filters — at Initial Version

Reported by: Dmitri Fedortchenko <zeraien@…> Owned by: nobody
Component: Template system Version: dev
Severity: Keywords: template filter
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.template.TokenParser is inconsistent
when parsing filters that follow constant strings or variables.

Meaning that:
{% tag thevar|filter sometag %} will produce:
self.value() = "thevar|filter"
self.tag() = "sometag"

However:
{% tag "a value"|filter sometag %} will produce:
self.value() = "a value"
self.tag() = "|filter"
self.tag() = "sometag"

This does not seem like correct behaviour...
I made a very simple patch for this, thus the outcome of the above:

{% tag "a value"|filter sometag %} will produce:
value = "a value"|filter
tag = sometag

So now we can simply pass the "value" into a FilterExpression to parse
the filters...

PS: I had trouble naming an internal method, feel free to complain about the name ;)

Change History (1)

by Dmitri Fedortchenko <zeraien@…>, 17 years ago

Attachment: tokenparser_filter_fix.diff added

The patch

Note: See TracTickets for help on using tickets.
Back to Top