Ah, so it is. Thank you. Somehow I overlooked that one.
Any commentary on the filter implementation? My use case above, for `
{% firstof ... %}` was a little dodgy. A better use case would be
using the filter with the "with" tag. I've thought however that
altering "with" to also accept the "in" syntax would eliminate the
need for the filter.
Apologies for overlooking docs on the smarter if tag. I had read the
roadmap in passing several days ago, but had thought it was only
simplifying the various if-tags that currently exist.
Tim
On Nov 10, 1:56 pm, Alex Gaynor <[email protected]> wrote:
> On Tue, Nov 10, 2009 at 3:54 PM, Tim <[email protected]> wrote:
>
> > 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:
>
> > �[email protected](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
>
> This is already covered by the Templates-02 item on the 1.2 features
> list, the smart-if tag. This tag includes support for "in"
> operations.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---