Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #1231 -- Added documentation for {% spaceless %} tag to the aut…

…o-generated template-tag docs in the admin

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2012 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f1f2005c05061030711b6cf3a9418d1e5223907a 1 parent d5a5f0f
Adrian Holovaty adrianholovaty authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 django/core/template/defaulttags.py
25 django/core/template/defaulttags.py
View
@@ -735,6 +735,31 @@ def regroup(parser, token):
regroup = register.tag(regroup)
def spaceless(parser, token):
+ """
+ Normalize whitespace between HTML tags to a single space. This includes tab
+ characters and newlines.
+
+ Example usage::
+
+ {% spaceless %}
+ <p>
+ <a href="foo/">Foo</a>
+ </p>
+ {% spaceless %}
+
+ This example would return this HTML::
+
+ <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::
+
+ {% spaceless %}
+ <strong>
+ Hello
+ </strong>
+ {% spaceless %}
+ """
nodelist = parser.parse(('endspaceless',))
parser.delete_first_token()
return SpacelessNode(nodelist)
Please sign in to comment.
Something went wrong with that request. Please try again.