ElementCreator

open class ElementCreator<out PARENT_TYPE : Element>(parent: PARENT_TYPE, parentCreator: ElementCreator<*>?, position: Int?)

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

ElementCreator
Link copied to clipboard
fun <out PARENT_TYPE : Element> ElementCreator(parent: PARENT_TYPE, parentCreator: ElementCreator<*>? = parent.creator, position: Int? = null)

Types

Companion
Link copied to clipboard
object Companion : KLogging

Functions

cleanup
Link copied to clipboard
fun cleanup()
element
Link copied to clipboard
fun element(tag: String, attributes: Map<String, JsonPrimitive> = attr, namespace: String? = null): Element
Create a new element, specifying its tag and attributes.
onCleanup
Link copied to clipboard
fun onCleanup(withParent: Boolean, f: Cleaner)
Specify a listener to be called when this element is removed from the DOM.
require
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.
text
Link copied to clipboard
fun text(text: String)
fun text(text: KVal<String>)

Properties

browser
Link copied to clipboard
val browser: WebBrowser
elementsCreatedCount
Link copied to clipboard
val elementsCreatedCount: Int
parent
Link copied to clipboard
val parent: PARENT_TYPE
parentCreator
Link copied to clipboard
val parentCreator: ElementCreator<*>?
position
Link copied to clipboard
val position: Int? = null

Extensions

a
Link copied to clipboard
fun ElementCreator<Element>.a(attributes: Map<String, JsonPrimitive> = emptyMap(), href: String? = null, new: ElementCreator<AElement>.() -> Unit? = null): AElement
br
Link copied to clipboard
fun ElementCreator<Element>.br(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<BrElement>.() -> Unit? = null): BrElement
button
Link copied to clipboard
fun ElementCreator<Element>.button(attributes: Map<String, JsonPrimitive> = emptyMap(), type: ButtonType? = ButtonType.button, autofocus: Boolean? = null, new: ElementCreator<ButtonElement>.() -> Unit? = null): ButtonElement
canvas
Link copied to clipboard
fun ElementCreator<Element>.canvas(attributes: Map<String, JsonPrimitive> = emptyMap(), width: Int, height: Int, new: ElementCreator<CanvasElement>.() -> Unit? = null): CanvasElement
closeOnElementCreatorCleanup
Link copied to clipboard
fun ElementCreator<*>.closeOnElementCreatorCleanup(kv: KVal<*>)
div
Link copied to clipboard
fun ElementCreator<Element>.div(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<DivElement>.() -> Unit? = null): DivElement
fileInput
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// @sample fileReaderSample
form
Link copied to clipboard
fun ElementCreator<Element>.form(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<FormElement>.() -> Unit? = null): FormElement
h1
Link copied to clipboard
fun ElementCreator<Element>.h1(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H1Element>.() -> Unit? = null): H1Element
h2
Link copied to clipboard
fun ElementCreator<Element>.h2(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H2Element>.() -> Unit? = null): H2Element
h3
Link copied to clipboard
fun ElementCreator<Element>.h3(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H3Element>.() -> Unit? = null): H3Element
h4
Link copied to clipboard
fun ElementCreator<Element>.h4(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H4Element>.() -> Unit? = null): H4Element
h5
Link copied to clipboard
fun ElementCreator<Element>.h5(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<H5Element>.() -> Unit? = null): H5Element
i
Link copied to clipboard
fun ElementCreator<Element>.i(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<IElement>.() -> Unit? = null): IElement
img
Link copied to clipboard
fun ElementCreator<Element>.img(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<ImageElement>.() -> Unit? = null): ImageElement
input
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, new: ElementCreator<InputElement>.() -> Unit? = null): InputElement
label
Link copied to clipboard
fun ElementCreator<Element>.label(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<LabelElement>.() -> Unit? = null): LabelElement
li
Link copied to clipboard
fun ElementCreator<Element>.li(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<LIElement>.() -> Unit? = null): LIElement
meta
Link copied to clipboard
fun ElementCreator<Element>.meta(attributes: Map<String, JsonPrimitive> = emptyMap(), name: String, content: String, httpEquiv: String? = null, charset: String? = null, new: ElementCreator<MetaElement>.() -> Unit? = null): MetaElement
nav
Link copied to clipboard
fun ElementCreator<Element>.nav(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<NavElement>.() -> Unit? = null): NavElement
ol
Link copied to clipboard
fun ElementCreator<Element>.ol(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<OLElement>.() -> Unit? = null): OLElement
option
Link copied to clipboard
fun ElementCreator<Element>.option(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<OptionElement>.() -> Unit? = null): OptionElement
p
Link copied to clipboard
fun ElementCreator<Element>.p(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<PElement>.() -> Unit? = null): PElement
render
Link copied to clipboard
fun <T> ElementCreator<*>.render(value: KVal<T>, container: ElementCreator<*>.() -> Element = { span().setAttribute("style", JsonPrimitive("display: contents;")) }, block: ElementCreator<Element>.(T) -> Unit)
renderEach
Link copied to clipboard
fun <ITEM : Any, EL : Element> ElementCreator<EL>.renderEach(orderedViewSet: OrderedViewSet<ITEM>, renderer: ElementCreator<EL>.(KVar<ITEM>) -> Unit)
// @sample ordered_view_set_sample
fun <T : Any> ElementCreator<*>.renderEach(list: KVar<List<T>>, block: ElementCreator<Element>.(value: KVar<T>) -> Unit)
Render each element of a List
route
Link copied to clipboard
fun ElementCreator<*>.route(routeReceiver: RouteReceiver.() -> Unit)
Route extension
section
Link copied to clipboard
fun ElementCreator<Element>.section(attributes: Map<String, JsonPrimitive> = emptyMap(), new: ElementCreator<SectionElement>.() -> Unit? = null): SectionElement
select
Link copied to clipboard
fun ElementCreator<Element>.select(attributes: Map<String, JsonPrimitive> = emptyMap(), name: String? = null, required: Boolean? = null, new: ElementCreator<SelectElement>.() -> Unit? = null): SelectElement