Tanguv0.35.0
CLI, terminal & markup8 exports
Raw Markdown

/repr/html

SHTML (#shtml / #html) node renderer, attribute/class utilities, and template formatter (format-html).

(use /repr/html)

Functions & symbols#

add-classes#

function
(add-classes attrs ...classes) -> None

Mutates `attrs:class` in place by appending `classes` without overwriting existing classes.

ParameterTypeOptionalDescription
attrsMaprequiredMutable attributes Map
classesAnyrequiredOne or more class names/arrays/maps
Returns:Any
(repr-html/add-classes attrs "card" "elevated")

escape-html#

function
(escape-html text) -> String

Escapes HTML special characters (`&`, `<`, `>`, `"`, `'`) for safe text/attribute interpolation.

ParameterTypeOptionalDescription
textAnyrequiredRaw text or value to escape
Returns:Any
(repr-html/escape-html "<script>") ; -> "&lt;script&gt;"

format-class#

function
(format-class value) -> Array

Normalizes class strings, nested arrays, or conditional maps into a flat deduplicated Array of class tokens.

ParameterTypeOptionalDescription
valueAnyrequiredClass name String, Array, or Map of {:cls bool}
Returns:Any
(repr-html/format-class ["btn" {"is-active" true}])

format-html#

function
(format-html html-expr) -> String

Renders an `#shtml` / `#html` expression tree into valid HTML5 (normalizing boolean attributes per §2.4.2).

ParameterTypeOptionalDescription
html_exprAnyrequiredEvaluated SHTML node or list of nodes
Returns:Any
(repr-html/format-html #shtml [:p {:class "lead"} "Hello"])

format-html-template#

function
(format-html-template chunks slots [flags]) -> String

Runtime helper compiling interpolated HTML template literals safely.

ParameterTypeOptionalDescription
chunksArrayrequiredStatic HTML template chunks
slotsArrayrequiredInterpolated slot values
flagsStringoptionalOptional compiler escape mode flags
Returns:Any
(repr-html/format-html-template ["<p>" "</p>"] ["Hi"])

merge-attrs#

function
(merge-attrs ...maps) -> Map

Merges attribute Maps left-to-right while cleanly concatenating `:class` lists instead of replacing them.

ParameterTypeOptionalDescription
mapsMaprequiredAttribute maps to merge left-to-right
Returns:Any
(repr-html/merge-attrs {:class "btn"} extra-attrs)

parse-component-params#

function
(parse-component-params params-arr) -> Map

Normalizes `#shtml` custom component parameters into `{:attrs Map :children Array}`.

ParameterTypeOptionalDescription
paramsArrayrequiredVariadic SHTML component body `[attrs? ...children]`
Returns:Any
(let {:attrs attrs :children children} (repr-html/parse-component-params params))

shtml->html#

function
(shtml->html html-expr) -> String

Canonical alias of `format-html`: serializes `#shtml` nodes to an HTML string.

ParameterTypeOptionalDescription
html_exprAnyrequiredEvaluated SHTML node tree
Returns:Any
(repr-html/shtml->html [:div "Hello"])

Related modules