From: Matthijs Kooijman Date: Fri, 8 Feb 2008 23:15:52 +0000 (+0100) Subject: * Modify the gapless template tag to preserve wanted empty lines (marked with \\) X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=b82030de79f2cde6b3953a4d23d33901cbd9638d;p=matthijs%2Fprojects%2Fxerxes.git * Modify the gapless template tag to preserve wanted empty lines (marked with \\) --- diff --git a/tools/templatetags/gapless.py b/tools/templatetags/gapless.py index 9defba5..ca93a56 100644 --- a/tools/templatetags/gapless.py +++ b/tools/templatetags/gapless.py @@ -8,7 +8,7 @@ register = Library() def strip_empty_lines(value): """Return the given HTML with empty and all-whitespace lines removed.""" - return re.sub(r'\n[ \t]*(?=\n)', '', force_unicode(value)) + return re.sub(r'(\n[ \t]*|(?<=\n)\\\\)(?=\n)', '', force_unicode(value)) strip_empty_lines = allow_lazy(strip_empty_lines, unicode) class GaplessNode(Node): @@ -43,3 +43,5 @@ def gapless(parser, token): parser.delete_first_token() return GaplessNode(nodelist) gapless = register.tag(gapless) + +# vim: set sw=4 sts=4 expandtab: