From b82030de79f2cde6b3953a4d23d33901cbd9638d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 9 Feb 2008 00:15:52 +0100 Subject: [PATCH] * Modify the gapless template tag to preserve wanted empty lines (marked with \\) --- tools/templatetags/gapless.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: -- 2.30.2