.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> </array>
</dict> </dict>
</array> </array>
<!-- flet: end of deep linking {% endif %} --> <!-- {% macro render_dict(d) -%} -->
<!-- flet: prop {% for k, v in cookiecutter.options.info_plist.items() %} --> <!-- {% for key, value in d.items() -%} -->
<key>{{ k }}</key> <key>{{ key }}</key>
<!-- flet: True {% if v == True %} --> <!-- {% if value is string -%} -->
<string>{{ value }}</string>
<!-- {% elif value == True %} -->
<true /> <true />
<!-- flet: False {% elif v == False %} --> <!-- {% elif value == False %} -->
<false /> <false />
<!-- flet: string value {% else %} --> <!-- {% elif value is mapping -%} -->
<string>{{ v }}</string> <dict>
<!-- flet: end of prop {% endif %} {% endfor %} --> {{ 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> </dict>
</plist> </plist>

View File

@ -31,6 +31,20 @@
<dict> <dict>
{{ render_dict(value) }} {{ render_dict(value) }}
</dict> </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 -%} {% endif -%}
{% endfor -%} {% endfor -%}
{% endmacro -%} {% endmacro -%}