diff -r ebaad720f88b -r 526ebd3988b0 web/lib/django_extensions/utils/text.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/django_extensions/utils/text.py Wed Jan 20 12:37:40 2010 +0100 @@ -0,0 +1,13 @@ +from django.utils.encoding import force_unicode +from django.utils.functional import allow_lazy + +def truncate_letters(s, num): + """ truncates a string to a number of letters, similar to truncate_words """ + s = force_unicode(s) + length = int(num) + if len(s)>length: + s = s[:length] + if not s.endswith('...'): + s += '...' + return s +truncate_letters = allow_lazy(truncate_letters, unicode)