From 897880b79b55f4450a86698d759ba6e4bf9faaef Mon Sep 17 00:00:00 2001 From: rnentjes Date: Mon, 11 Sep 2017 20:46:18 +0200 Subject: [PATCH] Add TD.include --- src/main/kotlin/nl/astraeus/komp/Komponent.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/nl/astraeus/komp/Komponent.kt b/src/main/kotlin/nl/astraeus/komp/Komponent.kt index c5c78bd..96d0d35 100644 --- a/src/main/kotlin/nl/astraeus/komp/Komponent.kt +++ b/src/main/kotlin/nl/astraeus/komp/Komponent.kt @@ -1,9 +1,6 @@ package nl.astraeus.komp -import kotlinx.html.DIV -import kotlinx.html.FORM -import kotlinx.html.SPAN -import kotlinx.html.TagConsumer +import kotlinx.html.* import kotlinx.html.dom.create import org.w3c.dom.Element import org.w3c.dom.HTMLElement @@ -30,6 +27,13 @@ fun FORM.include(component: Komponent) { Komponent.define(result, component) } +fun TD.include(component: Komponent) { + val result = component.render(this.consumer as TagConsumer) + + component.element = result + Komponent.define(result, component) +} + abstract class Komponent { var element: Element? = null var rendered = false