{# Macro to render a single field with its display label and value #} {% macro render_field(field_name, value, field_specs) %} {% set spec = field_specs.get(field_name) if field_specs else None %} {% set label = spec.label if (spec and spec.label) else (field_name | replace('_', ' ') | capitalize) %}
{{ label }}
{% if value is iterable and value is not string and value is not mapping %} {% if value | length > 0 %} {% else %} None {% endif %} {% elif value is mapping %}
{{ value | tojson(indent=2) }}
{% elif value is not none and value != '' %} {{ value }} {% else %} None {% endif %}
{% endmacro %} {# Macro to render a list of fields in Order using FormDef sections, excluding specified keys #} {% macro render_field_list(data_dict, form_def, field_specs, exclude_fields) %}
{% if form_def and form_def.sections %} {% for section in form_def.sections %} {% for field in section.fields %} {% if field not in exclude_fields %} {{ render_field(field, data_dict.get(field), field_specs) }} {% endif %} {% endfor %} {% endfor %} {% else %} {% for key, val in data_dict.items() %} {% if key not in exclude_fields and key not in ['form', 'stage_form', 'id', 'stage_type', 'display_name', 'feature_id', 'intent_stage', 'created', 'updated'] %} {{ render_field(key, val, field_specs) }} {% endif %} {% endfor %} {% endif %}
{% endmacro %}