Add context receiver extensions for DSLs

This commit is contained in:
sergeych committed 2026-04-29 20:49:50 +03:00
1 parent e107296bca
commit b2200e71ff
22 files changed
+860 -71

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
package lyng.io.html
/*
HTML helpers package.
API surface is intentionally empty for now; this package exists so Lyng code
can import `lyng.io.html` and grow declarations here incrementally.
*/
class HtmlBuilder {
private val head: List<String> = []
private val body: List<String> = []
fun build(): String =
"<HTML>" +
(head.isEmpty() ? "" : head.joinToString("\n")) +
(body.isEmpty() ? "" : body.joinToString("\n")) +
"</HTML>"
}
fun buildHtml(f: HtmlBuilder.()->void): String {
HtmlBuilder().apply(f).build()