[stable-2.8] Add compat tojson filter for jinja2 versions missing it (#56596) (#56606)

(cherry picked from commit 3f4a22d)

Co-authored-by: Matt Martz <matt@sivel.net>
This commit is contained in:
Toshio Kuratomi 2019-05-19 14:22:13 -07:00 committed by Alicia Cozine
parent c99ee40812
commit 40dbb28189

View file

@ -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