ElementCreator

open class ElementCreator<out PARENT_TYPE : Element>(val element: PARENT_TYPE, val parentCreator: ElementCreator<*>? = element.creator, val insertBefore: String? = null)(source)

Responsible for creating new DOM elements, and cleaning up Cleaners, KVars, and other related objects when DOM elements are deleted.

ElementCreator is typically used as a receiver for element creation functions like p or element.

Constructors

Link copied to clipboard
constructor(element: PARENT_TYPE, parentCreator: ElementCreator<*>? = element.creator, insertBefore: String? = null)

Types

Link copied to clipboard
object Companion : KLogging

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val insertBefore: String? = null
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun ElementCreator<Element>.a(attributes: Map<String, JsonPrimitive> = emptyMap(), href: String? = null, preventDefault: Boolean = true, new: ElementCreator<AElement>.(AElement) -> Unit? = null): AElement

Create an anchor element.

Link copied to clipboard
fun attr(receiver: PARENT_TYPE.() -> Unit)
Link copied to clipboard
fun ElementCreator<Element>.br(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<BrElement>.(BrElement) -> Unit? = null): BrElement
Link copied to clipboard
fun ElementCreator<Element>.button(attributes: Map<String, JsonPrimitive> = emptyMap(), type: ButtonType? = ButtonType.button, autofocus: Boolean? = null, new: ElementCreator<ButtonElement>.(ButtonElement) -> Unit? = null): ButtonElement
Link copied to clipboard
fun ElementCreator<Element>.canvas(attributes: Map<String, JsonPrimitive> = emptyMap(), width: Int, height: Int, new: ElementCreator<CanvasElement>.(CanvasElement) -> Unit? = null): CanvasElement
Link copied to clipboard
fun cleanup()
Link copied to clipboard

Close this AutoCloseable when this ElementCreator is cleaned up.

Link copied to clipboard
fun ElementCreator<Element>.div(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<DivElement>.(DivElement) -> Unit? = null): DivElement
Link copied to clipboard
fun element(receiver: PARENT_TYPE.() -> Unit)

fun element(tag: String, attributes: Map<String, JsonPrimitive> = attr, namespace: String? = null, new: ElementCreator<*>.(Element) -> Unit? = null): Element

Create a new element, specifying its tag and attributes.

Link copied to clipboard
fun elementScope(): CoroutineScope

Creates a CoroutineScope that will be cancelled when this ElementCreator is cleaned up.

Link copied to clipboard
fun ElementCreator<*>.fileInput(name: String? = null, initialValue: String? = null, size: Int? = null, placeholder: String? = null, attributes: Map<String, JsonPrimitive> = attr): FileFormInput

Create a FileReader

Link copied to clipboard
fun ElementCreator<Element>.footer(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<FooterElement>.(FooterElement) -> Unit? = null): FooterElement
Link copied to clipboard
fun ElementCreator<Element>.form(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<FormElement>.(FormElement) -> Unit? = null): FormElement
Link copied to clipboard
fun ElementCreator<Element>.h1(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H1Element>.(H1Element) -> Unit? = null): H1Element
Link copied to clipboard
fun ElementCreator<Element>.h2(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H2Element>.(H2Element) -> Unit? = null): H2Element
Link copied to clipboard
fun ElementCreator<Element>.h3(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H3Element>.(H3Element) -> Unit? = null): H3Element
Link copied to clipboard
fun ElementCreator<Element>.h4(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H4Element>.(H4Element) -> Unit? = null): H4Element
Link copied to clipboard
fun ElementCreator<Element>.h5(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H5Element>.(H5Element) -> Unit? = null): H5Element
Link copied to clipboard
fun ElementCreator<Element>.i(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<IElement>.(IElement) -> Unit? = null): IElement
Link copied to clipboard
fun ElementCreator<Element>.img(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<ImageElement>.(ImageElement) -> Unit? = null): ImageElement
Link copied to clipboard
fun ElementCreator<Element>.input(attributes: Map<String, JsonPrimitive> = emptyMap(), type: InputType? = null, name: String? = null, initialValue: String? = null, size: Int? = null, placeholder: String? = null, required: Boolean? = null, new: ElementCreator<InputElement>.(InputElement) -> Unit? = null): InputElement
Link copied to clipboard
fun <T> kval(initialValue: T): KVal<T>

Create a new KVar, and call KVar.close() when this ElementCreator is cleaned up.

Link copied to clipboard
fun <T> kvar(initialValue: T): KVar<T>

Create a new KVar, and call KVar.close() when this ElementCreator is cleaned up.

Link copied to clipboard
fun ElementCreator<Element>.label(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<LabelElement>.(LabelElement) -> Unit? = null): LabelElement
Link copied to clipboard
fun ElementCreator<Element>.li(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<LIElement>.(LIElement) -> Unit? = null): LIElement
Link copied to clipboard
fun ElementCreator<Element>.link(rel: LinkRelationship, href: URL, hreflang: String? = null, attributes: Map<String, JsonPrimitive> = emptyMap()): Element
Link copied to clipboard
fun ElementCreator<Element>.main(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<MainElement>.(MainElement) -> Unit? = null): MainElement
Link copied to clipboard
fun ElementCreator<Element>.meta(attributes: Map<String, JsonPrimitive> = emptyMap(), name: String? = null, content: String? = null, httpEquiv: String? = null, charset: String? = null, new: ElementCreator<MetaElement>.(MetaElement) -> Unit? = null): MetaElement
Link copied to clipboard
fun ElementCreator<Element>.nav(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<NavElement>.(NavElement) -> Unit? = null): NavElement
Link copied to clipboard
fun ElementCreator<Element>.ol(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<OLElement>.(OLElement) -> Unit? = null): OLElement
Link copied to clipboard
fun onCleanup(withParent: Boolean, f: Cleaner)

Specify a listener to be called when this element is removed from the DOM.

Link copied to clipboard
fun ElementCreator<Element>.option(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<OptionElement>.(OptionElement) -> Unit? = null): OptionElement
Link copied to clipboard
fun ElementCreator<Element>.p(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<PElement>.(PElement) -> Unit? = null): PElement
Link copied to clipboard
Link copied to clipboard
fun <T : Any> ElementCreator<*>.renderEach(list: KVar<List<T>>, block: ElementCreator<Element>.(value: KVar<T>) -> Unit)

Render each element of a List

fun <ITEM : Any, EL : Element> ElementCreator<EL>.renderEach(observableList: ObservableList<ITEM>, itemRenderer: ElementCreator<Element>.(ITEM) -> Unit)

Similar to render, but renders a list of items, and updates the DOM when the list changes.

Link copied to clipboard
fun require(vararg plugins: KClass<out KwebPlugin>)

Specify that a specific plugin be provided in Kweb.plugins, throws an exception if not.

Link copied to clipboard
fun ElementCreator<*>.route(routeReceiver: RouteReceiver.() -> Unit)

Route extension

Link copied to clipboard
fun ElementCreator<Element>.section(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<SectionElement>.(SectionElement) -> Unit? = null): SectionElement
Link copied to clipboard
fun ElementCreator<Element>.select(attributes: Map<String, JsonPrimitive> = emptyMap(), name: String? = null, required: Boolean? = null, initialValue: String? = null, new: ElementCreator<SelectElement>.(SelectElement) -> Unit? = null): SelectElement