From df7cd976f5e8ec6ad34ce1784b1762bfc5b57790 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 30 Mar 2007 22:25:36 +0200 Subject: [PATCH] [svn] added everytime block handling --HG-- branch : trunk --- jinja/translators/python.py | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/jinja/translators/python.py b/jinja/translators/python.py index 67ce6a4..4bc4df1 100644 --- a/jinja/translators/python.py +++ b/jinja/translators/python.py @@ -352,31 +352,30 @@ class PythonTranslator(Translator): lines.append(' if False:\n yield None') # add the missing blocks - if blocks: - block_items = blocks.items() - block_items.sort() - dict_lines = [] - for name, items in block_items: - tmp = [] - for idx, item in enumerate(items): - # ensure that the indention is correct - self.indention = 1 - func_name = 'block_%s_%s' % (name, idx) - lines.extend([ - '\ndef %s(context):' % func_name, - ' ctx_push = context.push', - ' ctx_pop = context.pop', - ' if False:', - ' yield None' - ]) - lines.append(self.indent(self.nodeinfo(item, True))) - lines.append(self.handle_block(item, idx + 1)) - tmp.append('buffereater(%s)' % func_name) - dict_lines.append(' %r: %s' % ( - str(name), - _to_tuple(tmp) - )) - lines.append('\nblocks = {\n%s\n}' % ',\n'.join(dict_lines)) + block_items = blocks.items() + block_items.sort() + dict_lines = [] + for name, items in block_items: + tmp = [] + for idx, item in enumerate(items): + # ensure that the indention is correct + self.indention = 1 + func_name = 'block_%s_%s' % (name, idx) + lines.extend([ + '\ndef %s(context):' % func_name, + ' ctx_push = context.push', + ' ctx_pop = context.pop', + ' if False:', + ' yield None' + ]) + lines.append(self.indent(self.nodeinfo(item, True))) + lines.append(self.handle_block(item, idx + 1)) + tmp.append('buffereater(%s)' % func_name) + dict_lines.append(' %r: %s' % ( + str(name), + _to_tuple(tmp) + )) + lines.append('\nblocks = {\n%s\n}' % ',\n'.join(dict_lines)) # now get the real source lines and map the debugging symbols debug_mapping = [] -- 2.26.2