lustre_pipes/element

Types

pub type ChildlessElementScaffold(msg) =
  ElementScaffold(msg)
pub type Element(msg) =
  element.Element(msg)
pub type ElementScaffold(msg) =
  #(String, List(Attribute(msg)))
pub type TextContentElementScaffold(msg) =
  ElementScaffold(msg)

Constants

pub const none: fn() -> Element(a)

A function for rendering nothing. This is mostly useful for conditional rendering, where you might want to render something only if a certain condition is met.

pub const text: fn(String) -> Element(a)

A function for turning a Gleam string into a text node. Gleam doesn’t have union types like some other languages you may be familiar with, like TypeScript. Instead, we need a way to take a String and turn it into an Element somehow: this function is exactly that!

pub const to_document_string: fn(Element(a)) -> String

Converts an element to a string like to_string, but prepends a <!doctype html> declaration to the string. This is useful for rendering complete HTML documents.

If the provided element is not an html element, it will be wrapped in both a html and body element.

pub const to_document_string_builder: fn(Element(a)) ->
  StringTree

Converts an element to a StringBuilder like to_string_builder, but prepends a <!doctype html> declaration. This is useful for rendering complete HTML documents.

If the provided element is not an html element, it will be wrapped in both a html and body element.

pub const to_readable_string: fn(Element(a)) -> String

Converts an element to a StringBuilder like to_string_builder, but prepends a <!doctype html> declaration. This is useful for rendering complete HTML documents.

If the provided element is not an html element, it will be wrapped in both a html and body element.

pub const to_string: fn(Element(a)) -> String

Convert a Lustre Element to a string. This is not pretty-printed, so there are no newlines or indentation. If you need to pretty-print an element, reach out on the Gleam Discord or open an issue with your use case and we’ll see what we can do!

pub const to_string_builder: fn(Element(a)) -> StringTree

Convert a Lustre Element to a StringBuilder. This is not pretty-printed, so there are no newlines or indentation. If you need to pretty-print an element, reach out on the Gleam Discord or open an issue with your use case and we’ll see what we can do!

Functions

pub fn children(
  scaffold: #(String, List(Attribute(a))),
  children: List(Element(a)),
) -> Element(a)
pub fn element(tag: String) -> #(String, List(Attribute(a)))
pub fn empty(
  scaffold: #(String, List(Attribute(a))),
) -> Element(a)
pub fn keyed(
  scaffold: #(String, List(Attribute(a))),
  pairs: List(#(String, Element(a))),
) -> Element(a)
pub fn text_content(
  scaffold: #(String, List(Attribute(a))),
  content: String,
) -> Element(a)
Search Document