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

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): HtmlTagBuilder

Adds an attribute to this tag.

Link copied to clipboard
open override fun build(): String
Link copied to clipboard
fun className(className: String?): HtmlTagBuilder

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

Link copied to clipboard
fun classNames(vararg classNames: String?): HtmlTagBuilder

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

Link copied to clipboard

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

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

Link copied to clipboard

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 = {}): HtmlTagBuilder
fun tag(name: String, content: List<Node>): HtmlTagBuilder

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

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