mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #977 from jpmens/fromjson
Jinja2 filter from_json added, to_json renamed
This commit is contained in:
commit
9b6cf8db4f
1 changed files with 2 additions and 1 deletions
|
@ -241,7 +241,8 @@ def template_from_file(basedir, path, vars):
|
||||||
''' run a file through the templating engine '''
|
''' run a file through the templating engine '''
|
||||||
|
|
||||||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False)
|
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False)
|
||||||
environment.filters['tojson'] = json.dumps
|
environment.filters['to_json'] = json.dumps
|
||||||
|
environment.filters['from_json'] = json.loads
|
||||||
data = codecs.open(path_dwim(basedir, path), encoding="utf8").read()
|
data = codecs.open(path_dwim(basedir, path), encoding="utf8").read()
|
||||||
t = environment.from_string(data)
|
t = environment.from_string(data)
|
||||||
vars = vars.copy()
|
vars = vars.copy()
|
||||||
|
|
Loading…
Reference in a new issue