{#- Shared UI macros: inline SVG icons and the recursive setting editor. -#} {% macro icon(name, size=16) -%} {%- if name == "github" -%} {%- else -%} {%- endif -%} {%- endmacro %} {% macro add_form(skill_id, container_path, container_type, key_placeholder="New field name") %} {% endmacro %} {% macro render_node(skill_id, label, value, path, parent_type=none) %} {%- if value is boolean %}{% set ntype = "boolean" %} {%- elif value is number %}{% set ntype = "number" %} {%- elif value is string %}{% set ntype = "textarea" if "\n" in value else "string" %} {%- elif value is mapping %}{% set ntype = "object" %} {%- elif value is sequence %}{% set ntype = "array" %} {%- else %}{% set ntype = "string" %} {%- endif %}
{% if parent_type == "array" %}[{{ label }}]{% else %}{{ label }}{% endif %} {% if ntype in ("object", "array") %} {% endif %}
{% if ntype not in ("object", "array") %} {% endif %}
{% if ntype == "object" %}
{% for k, v in value.items() %}{{ render_node(skill_id, k, v, path + [k], "object") }}{% endfor %} {{ add_form(skill_id, path, "object") }}
{% elif ntype == "array" %}
{% for v in value %}{{ render_node(skill_id, loop.index0, v, path + [loop.index0], "array") }}{% endfor %} {{ add_form(skill_id, path, "array") }}
{% else %}
{% if value is boolean %}{{ "true" if value else "false" }}{% elif value is none %}null{% else %}{{ value }}{% endif %}
{% endif %}
{% endmacro %}