Slang::Runtime
Runtime helpers used by codegen-emitted templates.
The codegen emits direct << writes for the literal-and-static
common case. These helpers handle the dynamic cases where a runtime
value must be inspected before being emitted (presence-checked,
bool-aware attribute rendering, splat iteration).
Constants
Matches attribute names accepted via splat.
Matches event-handler attribute names (onclick, onmouseover, ...).
HTML attribute names whose values are URLs.
Instance methods
Emits a value to the buffer in HTML data context.
Ktistec::SafeHTML is emitted raw; Ktistec::SafeJSON is emitted
raw; any other value has .to_s applied and is HTML-escaped.
Emits a value to the buffer in HTML data context.
Ktistec::SafeHTML is emitted raw; Ktistec::SafeJSON is emitted
raw; any other value has .to_s applied and is HTML-escaped.
Emits a value to the buffer in HTML data context.
Ktistec::SafeHTML is emitted raw; Ktistec::SafeJSON is emitted
raw; any other value has .to_s applied and is HTML-escaped.
Emits a single attribute for an unwrapped name=expr source
form.
Ktistec::SafeAttrValue-> emitname="<value.to_s>"rawtrue-> emitnamefalse-> omit entirely- else -> emit
name="<HTML-escaped value.to_s>"
Ktistec::SafeHTML is intentionally not admitted raw here:
markup like <em>x</em> is safe in HTML data slots but would
render as visible text inside an attribute (the type lattice
treats the two destinations as distinct). It falls through to
the HTML-escape branch below.
Emits a single attribute for an unwrapped name=expr source
form.
Ktistec::SafeAttrValue-> emitname="<value.to_s>"rawtrue-> emitnamefalse-> omit entirely- else -> emit
name="<HTML-escaped value.to_s>"
Ktistec::SafeHTML is intentionally not admitted raw here:
markup like <em>x</em> is safe in HTML data slots but would
render as visible text inside an attribute (the type lattice
treats the two destinations as distinct). It falls through to
the HTML-escape branch below.
Emits a merged class="..." attribute combining a literal prefix
and any number of dynamic class sources.
Emits a value to the buffer in HTML comment context.
HTML-escapes (covers & < > " ') and breaks any -- run with a
numeric character reference, preventing early-close of the
surrounding <!-- ... -->. No type dispatch: Ktistec::SafeHTML
is not admitted raw, because its safety claim is HTML-data
context, not comment context (markup containing -- would break
out).
Iterates a splat hash, emitting each key/value pair as an
attribute. nil values are skipped.
When skip_class is true, the class key is suppressed -- the
caller has already routed its value through emit_class.
Emits a single URL attribute (href, src, ...).
Only Ktistec::SafeURI? is admitted. Plain String (or any other
type) at a URL-attribute callsite fails to compile. nil is
silently skipped.