Mercurial > hg-stable
changeset 23707:ae5447de4c11
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 31 Dec 2014 11:22:17 -0800 |
parents | 3314664606e6 |
children | a9f826c3eaf9 |
files | mercurial/templatefilters.py |
diffstat | 1 files changed, 2 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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__)