zio.blocks.html.ToJs
See theToJs companion object
Typeclass for values that can be safely interpolated into JavaScript via js"...".
This is a '''templating''' typeclass, not a code generator. It converts Scala values into JavaScript '''expressions''' (value literals). Every JavaScript expression is also a valid statement, so ToJs output works in all template contexts: inline event handlers, script content, and variable assignments. For JavaScript control flow (if/for/while), use Js("...") directly.
Instance behavior:
Stringis quoted with"and JS-escaped (including `` protection)- Numeric types render as unquoted literals
Booleanrenders astrue/falseOptionrenders as the value ornullList/Maprender as JSON arrays/objects- Types with a zio.blocks.schema.Schema auto-derive via JSON serialization
Attributes
- Companion
- object
- Source
- ToJs.scala
- Graph
-
- Supertypes
Members list
In this article