Skip to content

Commit

Permalink
Fixed #1231 -- Added documentation for {% spaceless %} tag to the aut…
Browse files Browse the repository at this point in the history
…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
adrianholovaty committed Jan 16, 2006
1 parent d5a5f0f commit f1f2005
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions django/core/template/defaulttags.py
Expand Up @@ -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)
Expand Down

0 comments on commit f1f2005

Please sign in to comment.