m3e/helpers

Values

pub fn boolean_attribute(
  name: String,
  value: Bool,
) -> attribute.Attribute(msg)

boolean_attribute creates an HTML boolean attribute (or nothing)

pub fn clamp_with_default(
  value: Int,
  min: Int,
  max: Int,
  default: Int,
) -> Int

clamp_with_default validates that an integer value is within a given range. If it is then the value itself is returned, else a default value is returned

pub fn option_attribute(
  option: option.Option(a),
  attribute_name_func: fn(a) -> String,
  attribute_value_func: fn(a) -> String,
  default_value: option.Option(a),
) -> attribute.Attribute(msg)

option_attribute creates an HTML attribute if an Option(a) has a value, else it creates either a default or attribute.none()

Parameters:

  • option: the Option value to convert to a Lustre Attribute(msg)
  • attribute_name_func: function to create the attribute’s name
  • attribute_value_func: function to create the attribute’s value
  • default_value: default Option value if option is None
pub fn slot(name: String) -> attribute.Attribute(msg)

slot is a shorthand for attribute(“slot”, name)

Search Document