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:
parent
b8c170a322
commit
3f4a22d8ef
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue