diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/List.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index c8252080..261555c9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -51,10 +51,11 @@ enum class LISTTYPE(internal val tagName: String) { * @param elements optional list of elements * @param rich determines if [elements] can contain HTML code * @param classes a set of CSS class names + * @param init an initializer extension function */ open class ListTag( type: LISTTYPE, elements: List<String>? = null, rich: Boolean = false, - classes: Set<String> = setOf() + classes: Set<String> = setOf(), init: (ListTag.() -> Unit)? = null ) : SimplePanel(classes) { /** * List type. @@ -81,6 +82,11 @@ open class ListTag( refresh() } + init { + @Suppress("LeakingThis") + init?.invoke(this) + } + override fun render(): VNode { val childrenElements = when (type) { LISTTYPE.UL, LISTTYPE.OL, LISTTYPE.UNSTYLED, LISTTYPE.INLINE -> elements?.map { el -> diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index 557784b0..91fa2587 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -87,10 +87,11 @@ enum class ALIGN(val className: String) { * @param rich determines if [text] can contain HTML code * @param align text align * @param classes a set of CSS class names + * @param init an initializer extension function */ open class Tag( type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, - classes: Set<String> = setOf() + classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null ) : SimplePanel(classes) { /** @@ -126,6 +127,11 @@ open class Tag( refresh() } + init { + @Suppress("LeakingThis") + init?.invoke(this) + } + override fun render(): VNode { return if (text != null) { if (rich) { |