I haven't seen any notes on the subject, so I pose the question:
Would there be warm reception for a new built-in filter called "in",
to provide the template system with the Pythonic keyword? A full-blow
`{% if a in B %}` syntax would be great, but either one works. The
template language so intentionally mimes Python keywords that it seems
odd that "in" is left out.
You can imagine the simplicity of a filter, but in the name of being
quite specific as to what I'm suggesting:
@register.filter(name="in")
def _in(needle, haystack):
return needle in haystack
Pardon the PHP-ism of variable names.
I realize this is simple enough for a little custom templatetag
library to implement outside of the Django core, but it *does* fill in
that hole in the template language that I mentioned. My little
internal debates can't decide if the "in" functionality makes a better
if-tag extension, or if it's better suited as a filter. (Or both.) A
Filter is more appealing to me, because it can be used in several
other constructs, most notably `{% firstof ... %}`, as a simple
argument: "a|in:b".
Thus:
1) Is this worth adding to the ticket system, with a patch, or
should I content myself to my little custom library filter?
2) If it's worth the consideration, would a filter, a tag or both be
most appropriate?
Opinions obviously are welcome.
Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---