Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored April 01, 2007
4  django/template/defaulttags.py
@@ -852,7 +852,7 @@ def regroup(parser, token):
852 852
 
853 853
 def spaceless(parser, token):
854 854
     """
855  
-    Normalize whitespace between HTML tags to a single space. This includes tab
  855
+    Removes whitespace between HTML tags. This includes tab
856 856
     characters and newlines.
857 857
 
858 858
     Example usage::
@@ -865,7 +865,7 @@ def spaceless(parser, token):
865 865
 
866 866
     This example would return this HTML::
867 867
 
868  
-        <p> <a href="foo/">Foo</a> </p>
  868
+        <p><a href="foo/">Foo</a></p>
869 869
 
870 870
     Only space between *tags* is normalized -- not space between tags and text. In
871 871
     this example, the space around ``Hello`` won't be stripped::
4  django/utils/html.py
@@ -39,8 +39,8 @@ def strip_tags(value):
39 39
     return re.sub(r'<[^>]*?>', '', value)
40 40
 
41 41
 def strip_spaces_between_tags(value):
42  
-    "Returns the given HTML with spaces between tags normalized to a single space"
43  
-    return re.sub(r'>\s+<', '> <', value)
  42
+    "Returns the given HTML with spaces between tags removed"
  43
+    return re.sub(r'>\s+<', '><', value)
44 44
 
45 45
 def strip_entities(value):
46 46
     "Returns the given HTML with all entities (&something;) stripped"
6  docs/templates.txt
@@ -757,7 +757,7 @@ i.e.::
757 757
 spaceless
758 758
 ~~~~~~~~~
759 759
 
760  
-Normalizes whitespace between HTML tags to a single space. This includes tab
  760
+Removes whitespace between HTML tags. This includes tab
761 761
 characters and newlines.
762 762
 
763 763
 Example usage::
@@ -770,9 +770,9 @@ Example usage::
770 770
 
771 771
 This example would return this HTML::
772 772
 
773  
-    <p> <a href="foo/">Foo</a> </p>
  773
+    <p><a href="foo/">Foo</a></p>
774 774
 
775  
-Only space between *tags* is normalized -- not space between tags and text. In
  775
+Only space between *tags* is removed -- not space between tags and text. In
776 776
 this example, the space around ``Hello`` won't be stripped::
777 777
 
778 778
     {% spaceless %}
4  tests/regressiontests/templates/tests.py
@@ -522,8 +522,8 @@ def test_templates(self):
522 522
             ### I18N ##################################################################
523 523
 
524 524
             # {% spaceless %} tag
525  
-            'spaceless01': ("{% spaceless %} <b>    <i> text </i>    </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
526  
-            'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b> <i> text </i> </b>"),
  525
+            'spaceless01': ("{% spaceless %} <b>    <i> text </i>    </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
  526
+            'spaceless02': ("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", {}, "<b><i> text </i></b>"),
527 527
             'spaceless03': ("{% spaceless %}<b><i>text</i></b>{% endspaceless %}", {}, "<b><i>text</i></b>"),
528 528
 
529 529
             # simple translation of a string delimited by '

0 notes on commit 9191fa1

Please sign in to comment.
Something went wrong with that request. Please try again.