Saltstack Official PHP Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

28 行
898B

  1. # Returns a generic block of values suitable for inclusion in most states.
  2. {% macro sls_block(dict, ind=4) %}
  3. {% for key, value in dict.items() %}
  4. {{ '-'|indent(ind, True) }} {{ key }}: {{ value|json() }}
  5. {% endfor %}
  6. {% endmacro %}
  7. # Serializes dicts into sequenced data
  8. {%- macro serialize(data) -%}
  9. {%- if data is mapping -%}
  10. {%- set ret = [] -%}
  11. {%- for key, value in data.items() -%}
  12. {%- set value = serialize(value)|load_json() -%}
  13. {%- do ret.append({key: value}) -%}
  14. {%- endfor -%}
  15. {%- elif data is iterable and data is not string -%}
  16. {%- set ret = [] -%}
  17. {%- for value in data -%}
  18. {%- set value = serialize(value)|load_json() -%}
  19. {%- do ret.append(value) -%}
  20. {%- endfor -%}
  21. {%- else -%}
  22. {% set ret = data %}
  23. {%- endif -%}
  24. {{ ret|json() }}
  25. {%- endmacro -%}