From b02bb933fd6a60f9634fbb436242fec8980937bf Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 16 Jan 2006 19:00:24 +0000 Subject: [PATCH] magic-removal: Merged to [2012] git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2013 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/defaulttags.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 2d8cdd6d26..363147289a 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -734,6 +734,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 %} +

+ Foo +

+ {% spaceless %} + + This example would return this HTML:: + +

Foo

+ + Only space between *tags* is normalized -- not space between tags and text. In + this example, the space around ``Hello`` won't be stripped:: + + {% spaceless %} + + Hello + + {% spaceless %} + """ nodelist = parser.parse(('endspaceless',)) parser.delete_first_token() return SpacelessNode(nodelist)