{# Shared template macros. #} {# Per-figure debug line: renders only when CTDCAST_REPORT_DEBUG is set (figdbg() then returns a non-empty string). Guarding on figdbg() rather than a debug flag means the macro needs no `with context` and is a true no-op when off. #} {% macro dbg(b64, slot) %}{% set d = figdbg(b64) %}{% if d %}
slot: {{ slot }} | {{ d }}
{% endif %}{% endmacro %} {# Render one resolved manifest panel. `|safe` appears once, gated by kind, so figure payloads (base64) are always escaped into an image src and only html/table markup is emitted raw — the autoescape boundary is this one branch. #} {% macro panel(p, slot=None) %} {%- set sl = slot or p.slot %} {%- if p.is_stub %}

{{ p.caption or p.id }} — {{ p.stub_reason }}

{%- elif p.kind == "figure" %}
{{ p.caption or p.id }} {{- dbg(p.payload, sl) }} {%- if p.caption %}
{{ p.caption }}
{% endif %}
{%- else %}{# html | table #} {{ p.payload | safe }} {%- endif %} {% endmacro %} {# The one place a section number + title is formatted: "(1) Overview", or just "Overview" when there is no number. Every page — the manifest-driven bodies AND the hand-authored casts/sections/timeseries listing pages — renders headings and jump-nav links through this, so the numbering style is chosen once. #} {% macro heading_text(number, title) %}{% if number %}({{ number }}) {% endif %}{{ title }}{% endmacro %} {# Render a resolved report body: the jump-nav plus every numbered section and its panels. Shared by every manifest-driven page (cast, section, and later timeseries / index) so section numbering, anchors and layout live in one place. Section numbers show as "(1) Title"; a section in `section_columns` stacks its trailing panels (from that index) into a right-hand fig-col. `legacy_anchor_spans` is a Jinja global emitting the D3 transition anchors. #} {% macro report_body(report, section_columns={}, center_sections=[]) %}
{% for s in report.sections %}{{ heading_text(s.number, s.title) }} {% endfor %}
{% for s in report.sections %}

{{ heading_text(s.number, s.title) }}

{{ legacy_anchor_spans([s.id]) | safe }} {% if s.intro %}

{{ s.intro }}

{% endif %} {% set split = section_columns.get(s.id) %}
{# split only takes the fig-col path when the section actually has a panel at that index; a section whose panels dropped below it falls back to a flat row. #} {% if split is not none and s.panels|length > split %} {% for p in s.panels %}{% if loop.index0 < split %}{{ panel(p) }}{% endif %}{% endfor %}
{% for p in s.panels %}{% if loop.index0 >= split %}{{ panel(p, "full") }}{% endif %}{% endfor %}
{% else %} {% for p in s.panels %}{{ panel(p) }}{% endfor %} {% endif %}
{% endfor %} {% if not report.sections %}

No plottable data for this selection.

{% endif %} {% if report.not_applicable %}

Not applicable to this {% if report.sections %}selection{% else %}deployment{% endif %}: {{ report.not_applicable | join(", ") }}.

{% endif %} {% endmacro %} {# Cross-navigation pill bar linking the compiled-file inventory pages (profiles.nc / ladcp_profiles.nc / SBE sensors). The page matching current_href is rendered as a non-link active pill. Requires the .inventory-strip / .file-pill CSS (in each page's head_extra). #} {% macro inventory_pills(pills, current_href="") %} {% if pills %} {% endif %} {% endmacro %}