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 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
|
||||
|
|
Loading…
Reference in a new issue