lustre/element

To read the full documentation for this module, please visit https://lustre.build/api/lustre/element

Types

pub opaque type Element(msg)

Functions

pub fn advanced(
  namespace: String,
  tag: String,
  attrs: List(Attribute(a)),
  children: List(Element(a)),
  self_closing: Bool,
  void: Bool,
) -> Element(a)
pub fn element(
  tag: String,
  attrs: List(Attribute(a)),
  children: List(Element(a)),
) -> Element(a)

🚨 Because Lustre is primarily used to create HTML, this function spcieal-cases the following tags to be self-closing:

  • area
  • base
  • br
  • col
  • embed
  • hr
  • img
  • input
  • link
  • meta
  • param
  • source
  • track
  • wbr

This will only affect the output of to_string and to_string_builder! If you need to render any of these tags with children, or you want to render some other tag as self-closing or void, use advanced instead.

pub fn map(element: Element(a), f: fn(a) -> b) -> Element(b)
pub fn namespaced(
  namespace: String,
  tag: String,
  attrs: List(Attribute(a)),
  children: List(Element(a)),
) -> Element(a)
pub fn none() -> Element(a)
pub fn text(content: String) -> Element(a)
pub fn to_string(element: Element(a)) -> String
pub fn to_string_builder(element: Element(a)) -> StringBuilder
Search Document