Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 31779:fd687ec5a643
templatefilters: drop callable support from json()
This backs out ae5447de4c11. A callable should be evaluated beforehand
by templater.runsymbol().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 02 Apr 2017 11:46:49 +0900 |
parents | 35eb8f112c88 |
children | 8d9eafe01111 |
comparison
equal
deleted
inserted
replaced
31778:ac69675fff1c | 31779:fd687ec5a643 |
---|---|
234 elif util.safehasattr(obj, '__iter__'): | 234 elif util.safehasattr(obj, '__iter__'): |
235 out = [] | 235 out = [] |
236 for i in obj: | 236 for i in obj: |
237 out.append(json(i)) | 237 out.append(json(i)) |
238 return '[' + ', '.join(out) + ']' | 238 return '[' + ', '.join(out) + ']' |
239 elif util.safehasattr(obj, '__call__'): | |
240 return json(obj()) | |
241 else: | 239 else: |
242 raise TypeError('cannot encode type %s' % obj.__class__.__name__) | 240 raise TypeError('cannot encode type %s' % obj.__class__.__name__) |
243 | 241 |
244 @templatefilter('lower') | 242 @templatefilter('lower') |
245 def lower(text): | 243 def lower(text): |