/repr/html
SHTML (#shtml / #html) node renderer, attribute/class utilities, and template formatter (format-html).
Functions & symbols#
add-classes#
Mutates `attrs:class` in place by appending `classes` without overwriting existing classes.
| Parameter | Type | Optional | Description |
|---|---|---|---|
attrs | Map | required | Mutable attributes Map |
classes | Any | required | One or more class names/arrays/maps |
Any(repr-html/add-classes attrs "card" "elevated")escape-html#
Escapes HTML special characters (`&`, `<`, `>`, `"`, `'`) for safe text/attribute interpolation.
| Parameter | Type | Optional | Description |
|---|---|---|---|
text | Any | required | Raw text or value to escape |
Any(repr-html/escape-html "<script>") ; -> "<script>"format-class#
Normalizes class strings, nested arrays, or conditional maps into a flat deduplicated Array of class tokens.
| Parameter | Type | Optional | Description |
|---|---|---|---|
value | Any | required | Class name String, Array, or Map of {:cls bool} |
Any(repr-html/format-class ["btn" {"is-active" true}])format-html#
Renders an `#shtml` / `#html` expression tree into valid HTML5 (normalizing boolean attributes per §2.4.2).
| Parameter | Type | Optional | Description |
|---|---|---|---|
html_expr | Any | required | Evaluated SHTML node or list of nodes |
Any(repr-html/format-html #shtml [:p {:class "lead"} "Hello"])format-html-template#
Runtime helper compiling interpolated HTML template literals safely.
| Parameter | Type | Optional | Description |
|---|---|---|---|
chunks | Array | required | Static HTML template chunks |
slots | Array | required | Interpolated slot values |
flags | String | optional | Optional compiler escape mode flags |
Any(repr-html/format-html-template ["<p>" "</p>"] ["Hi"])merge-attrs#
Merges attribute Maps left-to-right while cleanly concatenating `:class` lists instead of replacing them.
| Parameter | Type | Optional | Description |
|---|---|---|---|
maps | Map | required | Attribute maps to merge left-to-right |
Any(repr-html/merge-attrs {:class "btn"} extra-attrs)parse-component-params#
Normalizes `#shtml` custom component parameters into `{:attrs Map :children Array}`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
params | Array | required | Variadic SHTML component body `[attrs? ...children]` |
Any(let {:attrs attrs :children children} (repr-html/parse-component-params params))shtml->html#
Canonical alias of `format-html`: serializes `#shtml` nodes to an HTML string.
| Parameter | Type | Optional | Description |
|---|---|---|---|
html_expr | Any | required | Evaluated SHTML node tree |
Any(repr-html/shtml->html [:div "Hello"])