Add context receiver extensions for DSLs
This commit is contained in:
1 parent
e107296bca
commit
b2200e71ff
22 files changed
+860
-71
No files matched your search
@@ -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()
|
||||
Reference in new issue
Block a user