Construct escaped text. Use this for all untrusted or dynamic text.
Html
:= []
Build and render small server-generated HTML documents.
Text and attribute values are escaped by default. Tag and attribute names supplied to the generic constructors are trusted syntax and must be constants, not user input.
page = Html.html([], [
Html.body([], [
Html.h1([], [Html.text("Hello <Roc>")]),
Html.a([Attribute.href("/account")], [Html.text("Account")]),
]),
])
response = Response.from_status(200)
.with_headers([{ name: "Content-Type", value: "text/html; charset=utf-8" }])
.with_body(Str.to_utf8(Html.render(page)))
dangerously_include_unescaped_html : Str -> HtmlNode
Insert trusted HTML without escaping it.
Never pass user input or other untrusted content to this function.
Construct a normal element with a trusted tag name.
void_element : Str, List(Attribute) -> HtmlNode
Construct a void element with a trusted tag name.
Render a complete HTML document beginning with <!DOCTYPE html>.
render_without_doc_type : HtmlNode -> Str
Render a node without adding a document type declaration.
Construct an html element.
Construct a head element.
Construct a body element.
Construct a title element.
Construct a header element.
Construct a nav element.
Construct a main element.
Construct a div element.
Construct a span element.
Construct a p element.
Construct an a element.
Construct a ul element.
Construct an li element.
Construct an h1 element.
Construct an h2 element.
Construct an h3 element.
Construct an h4 element.
Construct an h5 element.
Construct an h6 element.
Construct a form element.
Construct a button element.
Construct a label element.
Construct a table element.
Construct a thead element.
Construct a tbody element.
Construct a tr element.
Construct a th element.
Construct a td element.
Construct an svg element.
Construct a select element.
Construct an option element.
Construct an input void element.
Construct a meta void element.
Construct a link void element.
Construct a br void element.
Node : HtmlNode
An HTML node. Prefer this module's constructors so text and attribute values are escaped consistently.