From patchwork Tue Feb 23 15:45:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7, of, 7] templatefilters: document json filter that requires UTF-8 bytes From: Yuya Nishihara X-Patchwork-Id: 13318 Message-Id: <02072a6dba91478d5f12.1456242332@mimosa> To: mercurial-devel@mercurial-scm.org Date: Wed, 24 Feb 2016 00:45:32 +0900 # HG changeset patch # User Yuya Nishihara # Date 1452939833 -32400 # Sat Jan 16 19:23:53 2016 +0900 # Node ID 02072a6dba91478d5f12fd52113dce45f0b2a8c3 # Parent 484371c3f9c61fd2694aae90b1c650dec203c596 templatefilters: document json filter that requires UTF-8 bytes I don't know why we haven't documented it, but "json" filter is essential for web templates. It should be a public template filter. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -193,6 +193,8 @@ def indent(text, prefix): return "".join(indenter()) def json(obj): + """:json: Any object. Serializes the object to a JSON formatted text. + Input text should be encoded in UTF-8.""" if obj is None or obj is False or obj is True: return {None: 'null', False: 'false', True: 'true'}[obj] elif isinstance(obj, int) or isinstance(obj, float):