1
我想過濾包含或以'foo_'開頭並忽略列表中的其他值的值。Jinja模板字典/列表過濾器「contains」或「like」 - Saltstack
值(不能修改):
TEST:
- foo_a
- foo_b
- bar_a
- bar_b
- test_c
模板:
{% for value in grains['TEST'] %}
- do something with value that contains "foo_"
{% endfor %}
我該怎麼辦呢?
我試着用:
{% for value in grains['TEST']|map(^foo_) %}
- do something with value that contains "foo_"
{% endfor %}
=>沒有成功
'{%for grain in'['TEST'] if value.startswith('foo_')%} - do something {%endfor%}' –