[PATCH 7 of 7] templatefilters: document json filter that requires UTF-8 bytes

Augie Fackler raf at durin42.com
Tue Feb 23 14:35:32 EST 2016


On Wed, Feb 24, 2016 at 12:45:32AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # 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've queued patches 1-6, but I have a fuzzy memory that mpm had a
reason to not document json. Matt?

>
> 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):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list