|
Last change
on this file since 9155 was 9006, checked in by dennisw, 15 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 | |
|---|
| 1 | from django.utils.encoding import force_unicode
|
|---|
| 2 | from django.utils.functional import allow_lazy
|
|---|
| 3 |
|
|---|
| 4 | def 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
|
|---|
| 13 | truncate_letters = allow_lazy(truncate_letters, unicode)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.