Generate HTML using functions, much like elm-html.
import html.{html, head, body, p, text, render_document}
import html/attributes.{class}
pub fn hello_world() -> String {
html([
head([], []),
body([
p([text("Hello, world!")], [class("big")])
], [])
], [])
|> render_document()
}
/// will return:
///
/// "<!doctype html><html><head></head><body><p class=\"big\">Hello, world!</p></body></html>"
If available on Hex this package can be added to your Gleam project:
gleam add html
and its documentation can be found at https://hexdocs.pm/ag_html.