On Aug 11, 7:50 am, Richard Davies <[email protected]> wrote: > Hi all, > > With 1.1 out of the door (great!), here's a thought for 1.2... > > I often end up writing the same couple of template tags and filters. I > think some of these are general enough and useful enough that they > should be considered for basic Django 1.2, even though they're fairly > easy to write as add-ons. Here is my wishlist - please feel free to > comment on any others that you would like to see and on any of mine > where I've missed an obvious way to use the existing tags. > > Filter: get > The built in dot (.) operator is great for accessing dictionary > lookup, attribute lookup, etc. However, it doesn't work when the > attribute/dictionary element is also a variable. I use a 'get' filter > with code like: > > {% for k in keys %} > Value for {{ k }} is {{ d|get:k }}<br/> > {% endfor %} > > where I'd like to just write d.k > > I couldn't find another way, and often end up writing this operator, > so think that it or an equivalent mechanism should be built in. > > Tag: ifstartswith > I find this very useful in writing menus, navigation bars, etc. since > I'm often checking whether the URL is within a given subdirectory. > > Filters: sort and sortreversed > We have dictsort and dictsortreversed already, but what about sorting > simple lists? e.g. > > {% for i in i_list|sortreversed %} > > Yes, I could usually sort the list before passing it into the > template, but it's nice to be able to do it in the template at well! > > Cheers, > > Richard.
I would add to your list a truncatechars style truncation filter. http://code.djangoproject.com/ticket/5025 seems to have the right idea. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
