From 40dbb28189897023ee1949e03e43c8869b27acc8 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 19 May 2019 14:22:13 -0700 Subject: [PATCH] [stable-2.8] Add compat tojson filter for jinja2 versions missing it (#56596) (#56606) (cherry picked from commit 3f4a22d) Co-authored-by: Matt Martz --- docs/bin/plugin_formatter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py index b136af59858..c4b4d0ec2fe 100755 --- a/docs/bin/plugin_formatter.py +++ b/docs/bin/plugin_formatter.py @@ -11,6 +11,7 @@ __metaclass__ = type import datetime import glob +import json import optparse import os import re @@ -399,6 +400,10 @@ def jinja2_environment(template_dir, typ, plugin_type): # Jinja < 2.10 env.filters['max'] = do_max + if 'tojson' not in env.filters: + # Jinja < 2.9 + env.filters['tojson'] = json.dumps + templates = {} if typ == 'rst': env.filters['rst_ify'] = rst_ify