Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed #1227 -- Fixed problem with new {% spaceless %} tag. It now nor…
…malizes spaces to a single space rather than no spaces

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1969 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jan 15, 2006
1 parent 0eaee6f commit e449e5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions django/utils/html.py
Expand Up @@ -38,8 +38,8 @@ def strip_tags(value):
return re.sub(r'<[^>]*?>', '', value)

def strip_spaces_between_tags(value):
"Returns the given HTML with spaces between tags stripped"
return re.sub(r'>\s+<', '><', value)
"Returns the given HTML with spaces between tags normalized to a single space"
return re.sub(r'>\s+<', '> <', value)

def strip_entities(value):
"Returns the given HTML with all entities (&something;) stripped"
Expand Down
7 changes: 4 additions & 3 deletions docs/templates.txt
Expand Up @@ -668,7 +668,8 @@ spaceless

**New in Django development version.**

Strips whitespace between HTML tags. This includes tab characters and newlines.
Normalizes whitespace between HTML tags to a single space. This includes tab
characters and newlines.

Example usage::

Expand All @@ -680,9 +681,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 stripped -- not space between tags and text. In
Only space between *tags* is normalized -- not space between tags and text. In
this example, the space around ``Hello`` won't be stripped::

{% spaceless %}
Expand Down

0 comments on commit e449e5c

Please sign in to comment.