added pretty print for context
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 21 Oct 2007 21:04:28 +0000 (23:04 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 21 Oct 2007 21:04:28 +0000 (23:04 +0200)
--HG--
branch : trunk

jinja/datastructure.py

index d265d8d1054fa2672dc57c29227040c24905c548..2408dd05fca0974ae9d03d58ee0596fc850374cf 100644 (file)
@@ -313,6 +313,17 @@ class Context(BaseContext):
         """
         return 'Context(%r)' % self.to_dict()
 
+    def __pretty__(self, p, cycle):
+        p.begin_group(9, 'Context({')
+        for idx, (key, value) in enumerate(self.to_dict().iteritems()):
+            if idx:
+                p.text(',')
+                p.breakable()
+            p.pretty(key)
+            p.text(': ')
+            p.pretty(value)
+        p.end_group(9, '})')
+
 
 class LoopContext(object):
     """