nakai

Nakai has several built-in “builders” that can be used.

Functions

pub fn to_inline_string(tree: Node) -> String

Renders only the provided HTML, exactly as provided (disables <head> deduplication, etc.), into a String. Useful for generating snippets instead of whole pages.

Examples

html.div_text([], "hello, lucy!")
|> nakai.to_inline_string()
pub fn to_inline_string_tree(tree: Node) -> StringTree

Renders only the provided HTML, exactly as provided (disables <head> deduplication, etc.), into a StringTree. Useful for generating snippets instead of whole pages.

Examples

html.div_text([], "hello, lucy!")
|> nakai.to_inline_string_tree()
pub fn to_string(tree: Node) -> String

Renders a full HTML document from the given tree, into a String.

Since Strings in Gleam are always UTF-8 encoded, Nakai will automatically set <meta charset="utf-8" />, as it’s the only option that makes sense, and will prevent incorrect rendering of glyphs if you don’t set it yourself.

Examples

html.div_text([], "hello, lucy!")
|> nakai.to_string()
pub fn to_string_tree(tree: Node) -> StringTree

Renders a full HTML document from the given tree, into a StringTree.

Since Strings in Gleam are always UTF-8 encoded, Nakai will automatically set <meta charset="utf-8" />, as it’s the only option that makes sense, and will prevent incorrect rendering of glyphs if you don’t set it yourself.

Examples

html.div_text([], "hello, lucy!")
|> nakai.to_string_tree()
Search Document