mirror of
https://github.com/django/django.git
synced 2025-06-08 13:09:13 +00:00
Fixed #3532 -- Made spaceless template tag remove all spaces, rather than preserving a single space. Thanks for the suggestion, ampaze@gmx.net.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1109e722aa
commit
9191fa1f64
@ -852,7 +852,7 @@ regroup = register.tag(regroup)
|
|||||||
|
|
||||||
def spaceless(parser, token):
|
def spaceless(parser, token):
|
||||||
"""
|
"""
|
||||||
Normalize whitespace between HTML tags to a single space. This includes tab
|
Removes whitespace between HTML tags. This includes tab
|
||||||
characters and newlines.
|
characters and newlines.
|
||||||
|
|
||||||
Example usage::
|
Example usage::
|
||||||
|
@ -39,7 +39,7 @@ def strip_tags(value):
|
|||||||
return re.sub(r'<[^>]*?>', '', value)
|
return re.sub(r'<[^>]*?>', '', value)
|
||||||
|
|
||||||
def strip_spaces_between_tags(value):
|
def strip_spaces_between_tags(value):
|
||||||
"Returns the given HTML with spaces between tags normalized to a single space"
|
"Returns the given HTML with spaces between tags removed"
|
||||||
return re.sub(r'>\s+<', '><', value)
|
return re.sub(r'>\s+<', '><', value)
|
||||||
|
|
||||||
def strip_entities(value):
|
def strip_entities(value):
|
||||||
|
@ -757,7 +757,7 @@ i.e.::
|
|||||||
spaceless
|
spaceless
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
Normalizes whitespace between HTML tags to a single space. This includes tab
|
Removes whitespace between HTML tags. This includes tab
|
||||||
characters and newlines.
|
characters and newlines.
|
||||||
|
|
||||||
Example usage::
|
Example usage::
|
||||||
@ -772,7 +772,7 @@ This example would return this HTML::
|
|||||||
|
|
||||||
<p><a href="foo/">Foo</a></p>
|
<p><a href="foo/">Foo</a></p>
|
||||||
|
|
||||||
Only space between *tags* is normalized -- not space between tags and text. In
|
Only space between *tags* is removed -- not space between tags and text. In
|
||||||
this example, the space around ``Hello`` won't be stripped::
|
this example, the space around ``Hello`` won't be stripped::
|
||||||
|
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user