Exporter
An Exporter is a simple container for capturing some return value. Its main purpose is to reduce boilerplate code if the value to be returned is created within some nested structure and would therefor need some preliminary defined var
outside the structure and some explicit return of the value afterwards.
It is best used implicitly by the corresponding export function.
// function wants to return an inner Tag `input`
fun RenderContext.renderSomeStructure() : HtmlTag<HTMLInputElement> {
return export {
// ^^^^^^^^^^^^^
// return captured value
div {
export(input {
// ^^^^^^^^^^^^
// capture the needed value; the input tag in this case!
type("text")
value(someStore.data)
})
}
}
}
Content copied to clipboard