mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #2027 -- added truncatewords_html filter that respects HTML tags whilst
truncating. Patch from SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@4468 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2a14daffb0
commit
5a0b72a6eb
3 changed files with 90 additions and 0 deletions
|
@ -87,6 +87,20 @@ u'\xeb'
|
|||
>>> truncatewords('A sentence with a few words in it', 'not a number')
|
||||
'A sentence with a few words in it'
|
||||
|
||||
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0)
|
||||
''
|
||||
|
||||
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2)
|
||||
'<p>one <a href="#">two ...</a></p>'
|
||||
|
||||
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4)
|
||||
'<p>one <a href="#">two - three <br>four ...</a></p>'
|
||||
|
||||
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5)
|
||||
'<p>one <a href="#">two - three <br>four</a> five</p>'
|
||||
|
||||
>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100)
|
||||
'<p>one <a href="#">two - three <br>four</a> five</p>'
|
||||
|
||||
>>> upper('Mixed case input')
|
||||
'MIXED CASE INPUT'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue