HtmlTagBuilder

class HtmlTagBuilder(name: String, renderer: BaseHtmlNodeRenderer, pretty: Boolean) : TagBuilder

A builder of an HTML tag.

Example:

val builder = tagBuilder("html") {
tag("head") {
tag("meta")
.attribute("charset", "UTF-8")
.void(true)
}
tag("body") {
+node.children
}

See also

tagBuilder

Constructors

Link copied to clipboard
constructor(name: String, renderer: BaseHtmlNodeRenderer, pretty: Boolean)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun append(content: CharSequence)
Link copied to clipboard
fun attribute(key: String, value: Any): <Error class: unknown class>

Adds an attribute to this tag.

Link copied to clipboard
open override fun build(): String
Link copied to clipboard
fun className(className: String?): <Error class: unknown class>

Applies a single class name via the class attribute to this tag.

Link copied to clipboard
fun classNames(vararg classNames: String?): <Error class: unknown class>

Applies a sequence of class names via the class attribute to this tag.

Link copied to clipboard
fun hidden(): <Error class: unknown class>

Adds a data-hidden attribute to this tag as a flag that this is a hidden element. A page that has either zero elements or only hidden elements is considered blank. This attribute is usually read by external stylesheets and scripts.

Link copied to clipboard
fun optionalAttribute(key: String, value: Any?): <Error class: unknown class>

Adds an attribute to this tag only if value is not null.

Link copied to clipboard
fun style(init: CssBuilder.() -> Unit): <Error class: unknown class>

Applies a CSS style via the style attribute to this tag. The attribute is not added if the generated CSS string is empty.

Link copied to clipboard
fun tag(name: String, init: HtmlTagBuilder.() -> Unit = {}): <Error class: unknown class>
fun tag(name: String, content: List<Node>): <Error class: unknown class>

Appends a sub-tag.

Link copied to clipboard
operator fun Node.unaryPlus()
operator fun CharSequence.unaryPlus()
operator fun List<Node>.unaryPlus()
Link copied to clipboard
fun void(isVoid: Boolean): <Error class: unknown class>

Sets whether this tag is void (without a closing tag).