2021-05-22 08:06:21 +00:00
|
|
|
{% macro dict_to_lua(dict) -%}
|
|
|
|
{
|
|
|
|
{%- for key, value in dict.items() -%}
|
2021-07-01 23:29:49 +00:00
|
|
|
["{{ key }}"] = {{ variable_to_lua(value) }}{% if not loop.last %},{% endif %}
|
2021-05-22 08:06:21 +00:00
|
|
|
{% endfor -%}
|
|
|
|
}
|
|
|
|
{%- endmacro %}
|
2021-07-04 20:21:53 +00:00
|
|
|
{% macro list_to_lua(list) -%}
|
|
|
|
{
|
|
|
|
{%- for key in list -%}
|
|
|
|
{{ variable_to_lua(key) }}{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor -%}
|
|
|
|
}
|
|
|
|
{%- endmacro %}
|
2021-07-01 23:29:49 +00:00
|
|
|
{%- macro variable_to_lua(value) %}
|
|
|
|
{%- if value is mapping -%}{{ dict_to_lua(value) }}
|
|
|
|
{%- elif value is boolean -%}{{ value | string | lower }}
|
2021-07-04 20:21:53 +00:00
|
|
|
{%- elif value is string -%}"{{ value | safe }}"
|
|
|
|
{%- elif value is iterable -%}{{ list_to_lua(value) }}
|
2021-07-01 23:29:49 +00:00
|
|
|
{%- else -%} {{ value | safe }}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endmacro -%}
|
2021-05-22 08:06:21 +00:00
|
|
|
{% macro dict_to_recipe(dict) -%}
|
|
|
|
{
|
|
|
|
{%- for key, value in dict.items() -%}
|
|
|
|
{"{{ key }}", {{ value | safe }}}{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor -%}
|
|
|
|
}
|
|
|
|
{%- endmacro %}
|