Expand description
Generation slot markers («FILL: …» / «IMG: …») — render-time resolution.
Mako’s app generator marks brand-identity fields it cannot know as fill
slots («FILL: what it is | a realistic default») and references images
only as slots («IMG: description of the image»). The markers stay RAW in
the committed site/index.surf so they remain editable; this module
resolves them in the FINAL rendered HTML only (called from
crate::render_html::render_site_page and
crate::render_html::render_site_single_file).
The pass is a linear scanner over the rendered document with a small
context state machine (text / inside-tag / script-style raw text). The
output HTML is machine-generated and well-formed — escape_html bans raw
< in text and attribute values — so the classification is sound:
«FILL: label | default»→ the default text (label when the default segment is missing or empty), in every context.|is the primary separator; when it is absent a spaced em-dash (label — default) is accepted as a fallback separator.«IMG: description»in text →<img class="surfdoc-img-slot" src=[IMG_SLOT_PLACEHOLDER_URI] alt="description" loading="lazy">.«IMG: description»inside a tag (src="…",style="…url('…')…") → the bare placeholder URI.«IMG: description»inside<script>/<style>content (JSON-LD etc.) → the description text only; never a tag.
Unterminated or malformed markers are left verbatim.
Constants§
- IMG_
SLOT_ PLACEHOLDER_ URI - Placeholder image for unresolved
«IMG:»slots: a self-contained SVG data URI (neutral surface, sun + mountains glyph).
Functions§
- resolve_
slot_ markers - Resolve generation slot markers in rendered HTML. See the module docs for
the marker grammar and per-context behavior. Returns the input unchanged
(no allocation beyond the move) when it contains no
«.