templatefilters.json: call functions
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 31 Dec 2014 11:22:17 -0800
changeset 23707 ae5447de4c11
parent 23706 3314664606e6
child 23708 a9f826c3eaf9
templatefilters.json: call functions The "changeset" template from hgweb is using a lambda in the "diffsummary" key. In preparation for enabling JSON output from hgweb, teach the json filter how to call functions.
mercurial/templatefilters.py
--- a/mercurial/templatefilters.py	Thu Jan 01 16:47:14 2015 -0600
+++ b/mercurial/templatefilters.py	Wed Dec 31 11:22:17 2014 -0800
@@ -208,6 +208,8 @@
         for i in obj:
             out.append(json(i))
         return '[' + ', '.join(out) + ']'
+    elif util.safehasattr(obj, '__call__'):
+        return json(obj())
     else:
         raise TypeError('cannot encode type %s' % obj.__class__.__name__)