Opened 16 years ago

Closed 16 years ago

#5874 closed (invalid)

Template variables inside filters are not parsed correctly

Reported by: Thejaswi Puthraya Owned by: nobody
Component: Template system Version: dev
Severity: 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

Whenever a variable is used in a filter's (have checked for slice only...might be applicable for other filters also) arguments it is wrongly parsed and we get a TemplateSyntaxError which says "slice requires 1 arguments, 0 provided".
From the traceback here is what I received on the output:
The token being

u'some_item.var2|slice:":{{ forloop.counter0'

Notice the missing "}}"

Here is the test code:

{% for some_item in many_items %}
  {{ some_item.var1 }} {{ some_item.var2|slice:":{{ forloop.counter0 }}" }}
{% endfor %}

Change History (1)

comment:1 by Malcolm Tredinnick, 16 years ago

Resolution: invalid
Status: newclosed

Template variables cannot be used inside other template variables like this. The parsing becomes too complex and it's almost always possible to do what you want in some other way. We aim to keep things simple at that level and variable indirection like this is out of scope.

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