Files
AndreaSlopFotografie/web/contract/host-injection/README.md
T
SluijsensandClaude Sonnet 5.5 16027f5688 Adds the neutral HTML, the data block helpers and the golden files of the host injection
cmsHtml.ts writes the plain list and banner HTML that sits between the CMS
markers; contract/host-injection holds the inputs, the expected HTML and the
rules the CMS host's C# template must follow. cmsData.ts reads, validates and
writes the cms-data block.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 16:05:42 +01:00

3.5 KiB

Host injection contract (ASF site and CMS host)

The ASF build leaves markers in the prerendered pages; the CMS host fills them from live data. This folder holds the golden files for the two list regions. For every NAME.input.json there is a NAME.expected.html: the host's template must give exactly that text (the file ends with one newline that is not part of the HTML) for that input. The ASF repo tests its own implementation (src/lib/cmsHtml.ts) against the same files; to change the contract, change the code and run UPDATE_GOLDEN=1 pnpm test src/lib/cmsHtml.test.ts, then send the new files to the CMS session. The files come from ASF commit: see git log -1 -- web/contract/host-injection in the ASF repo.

Inputs

  • offerings-*.input.json: the answer of GET /api/v1/offerings (an array).
  • banner-*.input.json: { "position": "top" | "bottom", "answer": <answer of GET /api/v1/offerings/banner?position=...> | null }; null is a 204.

Rules for the packages region (<!--CMS:OFFERINGS-HTML-->)

  1. Keep a package only when all hold: slug is a string matching ^[a-z0-9-]+$; title is a non-empty string after trimming; features is a non-empty array of non-empty strings (each trimmed); price is readable as whole euros above zero (below); the slug was not used by an earlier kept package (the first one wins). Trim all texts. Any other package is skipped.
  2. Order by displayOrder (a number; missing counts as 0), ties keep the given order.
  3. Price text to whole euros: trim, then the regex ^\D*?(\d{1,3}(?:\.\d{3})+|\d+)(?:,(?:-|0{1,2}))?\D*$; group 1 without dots is the amount; it must be a whole number above zero. So "€ 175", "€ 1.250", "175,-", "€ 175,00" are readable; "op aanvraag", "€ 12,50", "€ 0", "175 of 185" are not.
  4. Output: <ul class="cms-offerings"> + one <li> per package + </ul>; nothing at all (empty string) when no package is kept.
  5. Per package: <li class="cms-offering" data-slug="SLUG"[ data-featured="true"]> + <h3>NAME</h3> + <p class="cms-price">€&nbsp;AMOUNT</p> + <ul class="cms-features"> + <li>FEATURE</li>... + </ul> + <a href="/?pakket=SLUG#contact">Boek NAME</a> + </li>. data-featured="true" only when featured is the boolean true. AMOUNT uses a dot as thousands separator (1.250). The literal text &nbsp; is written, not a character. description, priceNote and ctaLabel are not used.
  6. Escape every text (name, features, slug, amount) as: & &amp;, < &lt;, > &gt;, " &quot;, ' &#39;.

Rules for the banner regions (<!--CMS:BANNER-TOP-HTML-->, <!--CMS:BANNER-BOTTOM-HTML-->)

  1. null answer: empty string. Bottom: the title is required, otherwise empty string. Top: title or text is required, otherwise empty string.
  2. Output <aside class="cms-banner"> + the parts that are present, joined by one space, + </aside>. Parts: <strong>TITLE</strong>, <span>TEXT</span>, <a href="URL">LABEL</a> (trim all texts; empty means absent).
  3. The link is written only when label and URL are both present and the URL is safe: it starts with https:// and parses as a URL, or it starts with one / (not //, no backslash). Otherwise the link part is left out.
  4. Escape as above (also in the href).

Where the region sits

<!--CMS:OFFERINGS-HTML-->…<!--/CMS:OFFERINGS-HTML--> (and the two banner pairs) are written by the build; the host replaces what is between the markers and leaves the markers. See aidlc-docs/features/asf-cms-host-injection/plan.md for the other markers (data block, JSON-LD price, inline price).