.plist to support arrays

This commit is contained in:
Feodor Fitsner 2025-02-18 15:20:01 -08:00
parent 0a5541b586
commit 9b2ef3bced
2 changed files with 45 additions and 8 deletions

View File

@ -66,15 +66,38 @@
</array>
</dict>
</array>
<!-- flet: end of deep linking {% endif %} -->
<!-- flet: prop {% for k, v in cookiecutter.options.info_plist.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<!-- {% macro render_dict(d) -%} -->
<!-- {% for key, value in d.items() -%} -->
<key>{{ key }}</key>
<!-- {% if value is string -%} -->
<string>{{ value }}</string>
<!-- {% elif value == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<!-- {% elif value == False %} -->
<false />
<!-- flet: string value {% else %} -->
<string>{{ v }}</string>
<!-- flet: end of prop {% endif %} {% endfor %} -->
<!-- {% elif value is mapping -%} -->
<dict>
{{ render_dict(value) }}
</dict>
<!-- {% elif value is sequence -%} {# Support for lists/arrays #} -->
<array>
<!-- {% for item in value -%} -->
<!-- {% if item is string -%} -->
<string>{{ item }}</string>
<!-- {% elif item == True %} -->
<true />
<!-- {% elif item == False %} -->
<false />
<!-- {% elif item is mapping -%} -->
<dict>
{{ render_dict(item) }}
</dict>
<!-- {% endif -%} -->
<!-- {% endfor -%} -->
</array>
<!-- {% endif -%} -->
<!-- {% endfor -%} -->
<!-- {% endmacro -%} -->
{{ render_dict(cookiecutter.options.info_plist) }}
</dict>
</plist>

View File

@ -31,6 +31,20 @@
<dict>
{{ render_dict(value) }}
</dict>
{% elif value is sequence -%} {# Support for lists/arrays #}
<array>
{% for item in value -%}
{% if item is string -%}
<string>{{ item }}</string>
{% elif item is boolean -%}
<{{ "true" if item else "false" }}/>
{% elif item is mapping -%}
<dict>
{{ render_dict(item) }}
</dict>
{% endif -%}
{% endfor -%}
</array>
{% endif -%}
{% endfor -%}
{% endmacro -%}