#8902: tags having problems with filtered variables using arguments with spacing
-----------------------------+----------------------------------------------
Reporter: kire | Owner: nobody
Status: new | Milestone: post-1.0
Component: Template system | Version: 1.0
Keywords: template tags | Stage: Unreviewed
Has_patch: 1 |
-----------------------------+----------------------------------------------
If you want to do something like this:
{{{ {% with activity.start_date|date:"l j F" as date1 %} }}}
You'll get this error:
{{{ Exception Value: u'with' expected format is 'value as name' }}}
This is due to this code:
{{{
bits = list(token.split_contents())
if len(bits) != 4 or bits[2] != "as":
raise TemplateSyntaxError("%r expected format is 'value as name'"
%
bits[0])
}}}
First of all, maybe another bug: split_contents gave me a double "" on a
filter as |cut:" ", so I replaced it with contents.split() which worked
fine for me.
Then, this error: len(bits) !=4 is actually overkill. The tag works like
this: 0 -> tagname, 1-> a variable with filter, 2 -> as, 3 -> newvar.
Actually you should not check if the ' '-splitted content is 4 long, you
should check if [1] passes the compile_filter, which will throw it's own
error.
I tried to write a regex or iteration that really checked if you did
really passed 1 variable + filter(s), but that really isn't trivial, and
the compile_filter function's error is actually clear enough.
I added a patch + test for the {% with %} tag only at the moment (because
that's where I encountered the problem). However, other tags have the
problem also.
--
Ticket URL: <http://code.djangoproject.com/ticket/8902>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---