1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add compat tojson filter for jinja2 versions missing it (#56596)

This commit is contained in:
Matt Martz 2019-05-17 20:36:42 -05:00 committed by Alicia Cozine
parent b8c170a322
commit 3f4a22d8ef

View file

@ -11,6 +11,7 @@ __metaclass__ = type
import datetime import datetime
import glob import glob
import json
import optparse import optparse
import os import os
import re import re
@ -399,6 +400,10 @@ def jinja2_environment(template_dir, typ, plugin_type):
# Jinja < 2.10 # Jinja < 2.10
env.filters['max'] = do_max env.filters['max'] = do_max
if 'tojson' not in env.filters:
# Jinja < 2.9
env.filters['tojson'] = json.dumps
templates = {} templates = {}
if typ == 'rst': if typ == 'rst':
env.filters['rst_ify'] = rst_ify env.filters['rst_ify'] = rst_ify