* Modify the gapless template tag to preserve wanted empty lines (marked with \\)
authorMatthijs Kooijman <matthijs@stdio.flexvps.nl>
Fri, 8 Feb 2008 23:15:52 +0000 (00:15 +0100)
committerMatthijs Kooijman <matthijs@stdio.flexvps.nl>
Fri, 8 Feb 2008 23:15:52 +0000 (00:15 +0100)
tools/templatetags/gapless.py

index 9defba53502b398a78e4cca0993d4808e3d82d41..ca93a562e8737035f32da7bc83cfd300bede0798 100644 (file)
@@ -8,7 +8,7 @@ register = Library()
 \r
 def strip_empty_lines(value):\r
     """Return the given HTML with empty and all-whitespace lines removed."""\r
-    return re.sub(r'\n[ \t]*(?=\n)', '', force_unicode(value))\r
+    return re.sub(r'(\n[ \t]*|(?<=\n)\\\\)(?=\n)', '', force_unicode(value))\r
 strip_empty_lines = allow_lazy(strip_empty_lines, unicode)\r
 \r
 class GaplessNode(Node):\r
@@ -43,3 +43,5 @@ def gapless(parser, token):
     parser.delete_first_token()\r
     return GaplessNode(nodelist)\r
 gapless = register.tag(gapless)\r
+\r
+# vim: set sw=4 sts=4 expandtab:\r