Adding custom tags (SVG example)
fun Div.svg(width: Int, height: Int, block: CustomTag.() -> Unit = {}) {
customTag("svg") {
setAttribute("width", "$width")
setAttribute("height", "$height")
block()
}
}
fun CustomTag.line(x1: Int, y1: Int, x2: Int, y2: Int, stroke: Col, block: CustomTag.() -> Unit = {}) {
customTag("line") {
setAttribute("x1", "$x1")
setAttribute("y1", "$y1")
setAttribute("x2", "$x2")
setAttribute("y2", "$y2")
setAttribute("stroke", stroke.name)
block()
}
}Last updated