Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 9191fa1f644481d2e9a0495f9585f9bf1e83d87e 1 parent 1109e72
Russell Keith-Magee freakboy3742 authored
4 django/template/defaulttags.py
View
@@ -852,7 +852,7 @@ def regroup(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.
Example usage::
@@ -865,7 +865,7 @@ def spaceless(parser, token):
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
this example, the space around ``Hello`` won't be stripped::
4 django/utils/html.py
View
@@ -39,8 +39,8 @@ def strip_tags(value):
return re.sub(r'<[^>]*?>', '', value)
def strip_spaces_between_tags(value):
- "Returns the given HTML with spaces between tags normalized to a single space"
- return re.sub(r'>\s+<', '> <', value)
+ "Returns the given HTML with spaces between tags removed"
+ return re.sub(r'>\s+<', '><', value)
def strip_entities(value):
"Returns the given HTML with all entities (&something;) stripped"
6 docs/templates.txt
View
@@ -757,7 +757,7 @@ i.e.::
spaceless
~~~~~~~~~
-Normalizes whitespace between HTML tags to a single space. This includes tab
+Removes whitespace between HTML tags. This includes tab
characters and newlines.
Example usage::
@@ -770,9 +770,9 @@ Example usage::
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::
{% spaceless %}
4 tests/regressiontests/templates/tests.py
View
@@ -522,8 +522,8 @@ def test_templates(self):
### I18N ##################################################################
# {% spaceless %} tag
- 'spaceless01': ("{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
- 'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
+ 'spaceless01': ("{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
+ 'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
'spaceless03': ("{% spaceless %}<b><i>text</i></b>{% endspaceless %}", {}, "<b><i>text</i></b>"),
# simple translation of a string delimited by '
Please sign in to comment.
Something went wrong with that request. Please try again.