Added a new filter to truncate a string based on character count, rather than word count.

- Legacy-Id: 1502
This commit is contained in:
Henrik Levkowetz 2009-07-24 14:15:11 +00:00
parent 64b4f074d1
commit 0a285b84a5

View file

@ -260,6 +260,14 @@ def truncatemore(text, arg):
words.append(format % link)
return ' '.join(words)
@register.filter(name='trunc')
def trunc(text, arg):
num = int(arg)
if len(text) > num:
return text[:num-1]+"…"
else:
return text
@register.filter(name="wrap_long_lines")
def wrap_long_lines(text):
"""Wraps long lines without loosing the formatting and indentation