Hi all, I needed a nice way of saying "mike's friends" in a template when the currently logged in user was "mike", but "james' friends" when it was james. I realise this is a very English biased filter, but here's a patch to add it to defaultfilters in template.
Cheers, MikeH --- django0.96/template/defaultfilters.py 2007-03-10 08:11:28.000000000 +0000 +++ django/template/defaultfilters.py 2007-06-17 20:02:50.000000000 +0100 @@ -551,6 +551,15 @@ pass return singular_suffix +def possesive(value): + """ + Returns a possesive form of a name according to English rules + Mike returns Mike's, while James returns James' + """ + if value[-1] == 's': + return "%s'" % value + return "%s's" % value + def phone2numeric(value): "Takes a phone number and converts it in to its numerical equivalent" from django.utils.text import phone2numeric @@ -593,6 +602,7 @@ register.filter(make_list) register.filter(phone2numeric) register.filter(pluralize) +register.filter(possesive) register.filter(pprint) register.filter(removetags) register.filter(random) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---