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)))
text : Str -> HtmlNode

Construct escaped text. Use this for all untrusted or dynamic text.

render : HtmlNode -> Str

Render a complete HTML document beginning with <!DOCTYPE html>.

Node : HtmlNode

An HTML node. Prefer this module's constructors so text and attribute values are escaped consistently.