Is there a reason why the capfirst and title template filters don't
simply use the capitalize() and title() str methods?

The difference with capfirst is that it capitalizes the first character
without touching the others
>>> Template("{{ name|capfirst }}").render(Context({"name": "DOLORES"}))
'DOLORES'

whereas str.capitalize() will capitalize the first character and also
lower case the others
>>> "DOLORES".capitalize()
'Dolores'

The difference with title is that it lower case the character after a
single quote after a lower case character
>>> Template("{{ name|title }}").render(Context({"name": "de'errico"}))
"De'errico"

whereas str.title() will capitalize both
>>> "de'errico".title()
"De'Errico"

So why the special cases? Should we keep the filters consistent with
their str methods?
lower -> str.lower()
upper -> str.upper()
title -> str.title()

Should we rename capfirst? Or introduce a capitalize filter?
capitalize -> str.capitalize()


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to