From d306c8debc431086687c0b09bfc2c57a5a79854a Mon Sep 17 00:00:00 2001 From: Timothy Appnel Date: Tue, 28 Aug 2012 18:10:19 -0400 Subject: [PATCH] Add tojson filter to jinja environment used by the template module. --- lib/ansible/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 4d4d7fa96a7..6a7b678f315 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -211,6 +211,7 @@ def template_from_file(basedir, path, vars): ''' run a file through the templating engine ''' environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False) + environment.filters['tojson'] = json.dumps data = codecs.open(path_dwim(basedir, path), encoding="utf8").read() t = environment.from_string(data) vars = vars.copy()