Merge pull request #956 from tima/jinja-json-filter

Add tojson filter to jinja environment used by the template module.
This commit is contained in:
Michael DeHaan 2012-08-28 17:24:08 -07:00
commit 7ec0afbebc

View file

@ -241,6 +241,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()