macOS plist to support arrays

This commit is contained in:
Feodor Fitsner 2025-02-18 15:32:37 -08:00
parent d227d48247
commit 249407784b
1 changed files with 30 additions and 9 deletions

View File

@ -28,14 +28,35 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<!-- flet: prop {% for k, v in cookiecutter.options.info_plist.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<false />
<!-- flet: string value {% else %} -->
<string>{{ v }}</string>
<!-- flet: end of prop {% endif %} {% endfor %} -->
{% macro render_dict(d) -%}
{% for key, value in d.items() -%}
<key>{{ key }}</key>
{% if value is string -%}
<string>{{ value }}</string>
{% elif value is boolean -%}
<{{ "true" if value else "false" }}/>
{% 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 is boolean -%}
<{{ "true" if item else "false" }}/>
{% elif item is mapping -%}
<dict>
{{ render_dict(item) }}
</dict>
{% endif -%}
{% endfor -%}
</array>
{% endif -%}
{% endfor -%}
{% endmacro -%}
{{ render_dict(cookiecutter.options.info_plist) }}
</dict>
</plist>