# 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": | null }`; `null` is a 204. ## Rules for the packages region (``) 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: ``; nothing at all (empty string) when no package is kept. 5. Per package: `
  • ` + `

    NAME

    ` + `

    € AMOUNT

    ` + `` + `Boek NAME` + `
  • `. `data-featured="true"` only when `featured` is the boolean `true`. AMOUNT uses a dot as thousands separator (1.250). The literal text ` ` is written, not a character. `description`, `priceNote` and `ctaLabel` are not used. 6. Escape every text (name, features, slug, amount) as: `&` `&`, `<` `<`, `>` `>`, `"` `"`, `'` `'`. ## Rules for the banner regions (``, ``) 1. `null` answer: empty string. Bottom: the title is required, otherwise empty string. Top: title or text is required, otherwise empty string. 2. Output ``. Parts: `TITLE`, `TEXT`, `LABEL` (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 `…` (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).