{# Recursive macro for rendering a detail item (Field, Section, or Fieldset). Import with context so _span_map, _cols_map, record, _bare_in_section etc. are available. Section/Fieldset rendering is delegated to partials/sections/detail/.html. To add a new section type, create that partial — no changes needed here. inside_section controls layout behaviour: False (default) — top-level: field gets a wrapper
, in_section = _bare_in_section True — nested inside a section: no wrapper div, in_section = True Usage: {% from "partials/macros/detail_item.html" import render_item with context %} {{ render_item(item) }} #} {% macro render_item(item, inside_section=False) %} {% if item.is_section %} {% include ["partials/sections/detail/" + item.section_type + ".html", "partials/sections/detail/styled.html"] %} {% elif item.field_type != 'hidden' %} {# ── Plain field ─────────────────────────────────────────── #} {% set field = item %} {% set value = record | field_value(field.key) %} {% set span_class = _span_map[field.col_span] if field.col_span in _span_map else "" %} {% if inside_section %} {# No wrapper — the partial controls its own layout #} {% set in_section = True %} {% include ["partials/fields/detail/" + field.field_type + ".html", "partials/fields/detail/input.html"] %} {% else %} {# Top-level: wrap in a grid-cell div #} {% set in_section = _bare_in_section %}
{% include ["partials/fields/detail/" + field.field_type + ".html", "partials/fields/detail/input.html"] %}
{% endif %} {% endif %} {% endmacro %}