Le lundi 4 novembre 2013 14:13:44 UTC+1, Emanuele Bertoldi a écrit :
> What about the *add* filter? ;)
>
I forgot about that one.
However, there's probably a reason. It's hard to fix the templating engine
and implement a "+" operator. Because people would expect that whitespace
around the "+" should be possible. But that destroys almost all the
template tags now, because we first do token.split_contents in practically
every template tag, end then do var.resolve() on every part. Actually,
var.resolve() should receive the whole string. I think it should even
evaluate the "==" operator, what is done in the {% if %} tag now. (and the
length_is filter)
It's of course possible to add a "+" operator and allow all the built-in
tags to use it in var.resolve(), but it will take forever until all
external template tags have been fixed. People will expect the "+" to work
in any context.
I had a backwards-compatible patch to make writing template tags easier and
more consistent. I'd like to work toward such a consistent context free
grammar. The patches are from half a year ago, so not sure whether it
merges, but reviews are welcome.
https://code.djangoproject.com/ticket/20434
b.t.w, if we implement the []-operator, we can maybe use that for slicing
as well, instead of the slice filter that we have right now.
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/47ed653f-9dbd-46c2-8d44-74c3fef4ac09%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.