Added a new filter to truncate a string based on character count, rather than word count.
- Legacy-Id: 1502
This commit is contained in:
parent
64b4f074d1
commit
0a285b84a5
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue