Mercurial > hg
changeset 31780:8d9eafe01111
templatefilters: unroll handling of None/False/True
It doesn't make sense to use a dict here.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 02 Apr 2017 11:51:25 +0900 |
parents | fd687ec5a643 |
children | 47925b63be70 |
files | mercurial/templatefilters.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Sun Apr 02 11:46:49 2017 +0900 +++ b/mercurial/templatefilters.py Sun Apr 02 11:51:25 2017 +0900 @@ -219,8 +219,12 @@ @templatefilter('json') def json(obj): - if obj is None or obj is False or obj is True: - return {None: 'null', False: 'false', True: 'true'}[obj] + if obj is None: + return 'null' + elif obj is False: + return 'false' + elif obj is True: + return 'true' elif isinstance(obj, (int, long, float)): return str(obj) elif isinstance(obj, str):