Dieter Konrad
11/28/2020, 7:35 PMKotlinx.html
considered type safe?frank
11/28/2020, 8:10 PMKotlinx.html
is library for DSL to build HTML or for the DOM.
I understand for type-safety
when the compiler will validate types while compiling.
I found this in the documentation https://kotlinlang.org/docs/tutorials/javascript/typesafe-html-dsl.html
I'm a noob if there is someone with more experience who can explain us.nanodeath
11/28/2020, 9:05 PMnanodeath
11/28/2020, 9:06 PMfrank
11/29/2020, 9:09 AMDieter Konrad
11/29/2020, 9:30 AMbuildString { }
from StringBuilder
it is not typed because it is a string at the end. That is confusing to me. Cause when some html file statically retrieved from server over http it is also just text (string) I think.frank
11/29/2020, 2:19 PMbuildString {}
just run a scope function in the builderAction and return string value.
public inline fun buildString(builderAction: StringBuilder.() -> Unit): String {
contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }
return StringBuilder().apply(builderAction).toString()
}
Type-safe builders create domain-specific languages (DSLs) and hierarchical data structures.
PD: If there is someone with more experience to confirm it.nanodeath
11/30/2020, 5:23 PM