[svn] fix for misunderstood problem for #217
authorArmin Ronacher <armin.ronacher@active-4.com>
Mon, 5 Mar 2007 17:19:04 +0000 (18:19 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Mon, 5 Mar 2007 17:19:04 +0000 (18:19 +0100)
--HG--
branch : trunk

jinja/translators/python.py

index 4625fff676be59a9aa7bd55674de6e70218d49d7..be8eb3a7b3c78b45ce710a371acfad7fd1bb6f49 100644 (file)
@@ -273,6 +273,8 @@ class PythonTranslator(Translator):
         if node.recursive:
             write('def forloop(seq):')
             self.indention += 1
+            write('loopbuffer = []')
+            write('write = loopbuffer.append')
             write('context[\'loop\'].push(seq)')
             write('for %s in context[\'loop\']:' %
                 self.handle_node(node.item),
@@ -301,9 +303,10 @@ class PythonTranslator(Translator):
         # call recursive for loop!
         if node.recursive:
             write('context[\'loop\'].pop()')
+            write('return u\'\'.join(buffer)')
             self.indention -= 1
             write('context[\'loop\'] = LoopContext(None, context[\'loop\'], forloop)')
-            write('forloop(%s)' % self.handle_node(node.seq))
+            write('write(forloop(%s))' % self.handle_node(node.seq))
 
         write('context.pop()')
         return '\n'.join(buf)