On Tue, 2008-10-21 at 05:22 -0700, Jacek Fedorynski wrote:
> Hi,
> 
> I noticed that some of the default tags use token.split_contents() to
> parse their arguments, while others use token.contents.split(). At
> first glance, it seems that split_contents() is the smarter way to go,
> because it knows about quoted strings. Alas, there's a problem with
> filters. For example, this works:
> 
> {% for x in "somestring"|somefilter %}
> {% endfor %}
> 
> while this doesn't:
> 
> {% with "somestring"|somefilter as x %}
> {% endwith %}
> 
> That's because "for" uses token.contents.split() and "with" uses
> token.split_contents(), which splits before the pipe. Of course, if
> there was a space in "somestring", "for" would break.
> 
> Shouldn't split_contents() be modified to know about filters? And
> shouldn't all the tags use the same method for splitting their
> parameters? Or am I missing something here?

Basically, you're right. The main reason for the difference is
historical. Realise that a lot of stuff like the "with XYZ" usage is
relatively recent in Django's templating history.

We'll tidy up and uniformise a bunch of those inconsistencies in the
process of merging in a bunch of template tag parsing refactorings and
bug fixes that various people have done. It's a slightly slow process
due to the high impact of mistakes, but it will happen (I'm hoping to
get a bunch of the bug fixes in place before 1.0.1 is released, which
will act as a motivation for me).

There'll still be some differences at the end of the day, because some
tags have different lexing requirements than others. But making things
as uniform as possible is a good goal.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to