From: Armin Ronacher Date: Thu, 15 May 2008 11:23:26 +0000 (+0200) Subject: fixed error reporting for filtered statements X-Git-Tag: 2.0rc1~59 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1f627ffab40658ba8b7435de1b20fac6e56fce73;p=jinja2.git fixed error reporting for filtered statements --HG-- branch : trunk --- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 773203a..aaaad9d 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -1122,16 +1122,19 @@ class CodeGenerator(NodeVisitor): self.writeline('%s.append(' % frame.buffer) else: self.writeline('%s.extend((' % frame.buffer) + self.indent() for item in body: if isinstance(item, list): val = repr(concat(item)) if frame.buffer is None: self.writeline('yield ' + val) else: - self.write(val + ', ') + self.writeline(val + ', ') else: if frame.buffer is None: self.writeline('yield ') + else: + self.newline(item) close = 1 if self.environment.autoescape: self.write('escape(') @@ -1146,7 +1149,8 @@ class CodeGenerator(NodeVisitor): self.write(', ') if frame.buffer is not None: # close the open parentheses - self.write(len(body) == 1 and ')' or '))') + self.outdent() + self.writeline(len(body) == 1 and ')' or '))') # otherwise we create a format string as this is faster in that case else: @@ -1164,9 +1168,7 @@ class CodeGenerator(NodeVisitor): self.writeline('%s.append(' % frame.buffer) self.write(repr(concat(format)) + ' % (') idx = -1 - self.indent() for argument in arguments: - self.newline(argument) close = 0 if self.environment.autoescape: self.write('escape(') @@ -1175,9 +1177,8 @@ class CodeGenerator(NodeVisitor): self.write('environment.finalize(') close += 1 self.visit(argument, frame) - self.write(')' * close + ',') - self.outdent() - self.writeline(')') + self.write(')' * close + ', ') + self.write(')') if frame.buffer is not None: self.write(')')