saltstack/salt — pull request #6233 by johnnoone (2013-07-19 15:43:45+00:00)
Title: Jinja import yaml

This pull request complete the previous about adding yaml and json serializing.

It adds new jinja template filters and tags in order to parse as JSON or YAML any data or any templates.
With these tags, it became easy to resolve complex problems, like saltstack/salt#3991.

### Filters

**load_yaml** parse any string or variable string into yaml
**load_json** parse any string or variable string into json

the usage is:

{% set my_parsed_yaml = "{foo: bar}"|load_yaml %}
show me your foo : {{ my_parsed.foo }}

### Tags

**import_yaml** acts as import tag, but parse template as yaml
**import_json** acts as import tag, but parse template as json

for example:

```
# state_a.sls
foo: bar
baz:
qux: [1, 2, 3]
```

```
# state_b.sls
{% import_yaml 'state_a.sls' as imported %}
how many qux do you have? {{ imported.baz.qux|len }}
```