saltstack/salt — pull request #6328 by johnnoone (2013-07-26 16:01:31+00:00)
Title: Load jinja tag

Third pull-request of the serialization serie.

### new tags

Added load_yaml and load_json tags, which allows to decode blocks directly into variable.

```yaml
# doc1.sls
{% load_yaml as my_var %}
foo:
bar: qux
{% endload %}

{{ foo.bar }}
```

will print

```
qux
```

### exported variables

Revamped the whole serialization custom tags in order to exports these variables: now it's possible to import them with the {% import %} and {% from import %} jinja tags.

for example:

```yaml
{% import "doc1.sls" as doc %}
{{ doc.my_var.foo|json }}
```
or

```yaml
{% from "doc1.sls" import my_var as imported_var %}
{{ imported_var.foo|json }}
```
will also print

```
qux
```

With *set*, *macro*, *import*, *import_yaml*, *import_json*, *load_yaml*, *load_json*, it is easy to manage catalog of snippets or datasets directly in templates.