Title filter differs from Django implementation #62

Closed
runejuhl opened this Issue Jan 29, 2013 · 1 comment

Projects

None yet

2 participants

@runejuhl
Contributor

I'm not sure how much of an issue this really is, but Django's title filter upcases differently from the erlydtl title filter. Django will upcase all characters after quite a lot of tokens, including ' and !, due to the use of the Python str.title() function.

>>> import re
>>> def title(value):
...     """Converts a string into titlecase."""
...     t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
...     return re.sub("\d([A-Z])", lambda m: m.group(0).lower(), t)
... 
>>> title("string-String-ssTring123-STRING-123string-123STRING-!string-a?string")
'String-String-Sstring123-String-123string-123string-!String-A?String'

Compare this with

(runejerl@libertad)5> erlydtl_filters:title("string-String-ssTring123-STRING-123string-123STRING-!string-a?string").
"String-String-ssTring123-STRING-123string-123STRING-!string-a?string"

Any thoughts? Should erlydtl strive to follow Django templates as closely as possible?

@evanmiller
Contributor

ErlyDTL does strive to follow Django templates as closely as possible, so I'll leave this issue open until there is a resolution.

@evanmiller evanmiller closed this Jan 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment