saltstack/salt — pull request #10361 by johnnoone (2014-02-11 20:26:46+00:00)
Title: add sequence filter for jinja

the polymorphic nature of pillar and grains can leads to messy template.

for example, these 2 config files:

```jinja
# minion1.sls
grains:
role: web
```

```jinja
# minion2.sls
grains:
role:
- web
- db
```

must be expressed like that:

```jinja
# state.sls
{% if grains['role'] is list %}
{% set roles = grains['role'] %}
{% else %}
{% set roles = [grains['role']] %}
{% endif %}

{% for role in roles %}
- {{ role }}
{% endfor %}
```

this pull request adds a `sequence`jinja filter that standardizes any value to a list like value.
with this new filter, the previous template can be lighten to:

```jinja
# state.sls
{% set roles = grains['role'] | sequence %}

{% for role in roles %}
- {{ role }}
{% endfor %}
```