source: src/django_gheat/external/django-extensions/django_extensions/utils/text.py@ 9317

Last change on this file since 9317 was 9006, checked in by dennisw, 14 years ago

django_gheat - versie van gheat die gebruik maakt van django framework, ondersteunt SQL connecties in tegenstelling tot gheat dat gebruik maakt van sqlite

File size: 418 bytes
Line 
1from django.utils.encoding import force_unicode
2from django.utils.functional import allow_lazy
3
4def truncate_letters(s, num):
5 """ truncates a string to a number of letters, similar to truncate_words """
6 s = force_unicode(s)
7 length = int(num)
8 if len(s)>length:
9 s = s[:length]
10 if not s.endswith('...'):
11 s += '...'
12 return s
13truncate_letters = allow_lazy(truncate_letters, unicode)
Note: See TracBrowser for help on using the repository browser.