Merge pull request #1010 from tima/yaml-jinja
Added to_yaml and from_yaml filters to Jinja environment.
This commit is contained in:
commit
ba97ad13e3
1 changed files with 2 additions and 0 deletions
|
@ -243,6 +243,8 @@ def template_from_file(basedir, path, vars):
|
||||||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False)
|
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False)
|
||||||
environment.filters['to_json'] = json.dumps
|
environment.filters['to_json'] = json.dumps
|
||||||
environment.filters['from_json'] = json.loads
|
environment.filters['from_json'] = json.loads
|
||||||
|
environment.filters['to_yaml'] = yaml.dump
|
||||||
|
environment.filters['from_yaml'] = yaml.load
|
||||||
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