html_dsl/types/html/form

Types

Exists to prevent strings from being passed to forms

pub opaque type Input

An enum of all possible input types for an HTML input element.

pub type InputType {
  Button
  Checkbox
  Color
  Date
  DatetimeLocal
  Email
  File
  Hidden
  Image
  Month
  Number
  Password
  Radio
  Range
  Reset
  Search
  Submit
  Tel
  Text
  Time
  Url
  Week
}

Constructors

  • Button
  • Checkbox
  • Color
  • Date
  • DatetimeLocal
  • Email
  • File
  • Hidden
  • Image
  • Month
  • Number
  • Password
  • Radio
  • Range
  • Reset
  • Search
  • Submit
  • Tel
  • Text
  • Time
  • Url
  • Week

Functions

pub fn element(
  root root: Input,
  content content: String,
) -> Input

This function is used to create an Element

  • @param root: The root of the element
  • @param content: The content of the element
  • @returns: An Element
pub fn end(root: Input) -> String

Ends form context

  • @param root: The root of the form
  • @returns: The string representation of the form
pub fn form(attributes attributes: Option(Attribute)) -> Input

This creates a string that represents a form element

  • @param attributes: The attributes of the element
  • @returns: A string that represents the HTML element
pub fn input(
  root root: Input,
  attributes attributes: Option(Attribute),
  input_type input_type: InputType,
  placeholder placeholder: String,
) -> Input

This creates a string that represents an input element

  • @param root: The root of the element
  • @param attributes: The attributes of the element
  • @param input_type: The type of the input
  • @param placeholder: The placeholder of the input
  • @returns: An Input
pub fn input_to_string(input: Input) -> String

This function converts an Input to a string

  • @param input: The input to convert
  • @returns: The string representation of the input
pub fn input_type_to_attribute(input_type: InputType) -> String

A function that converts an input type to the corresponding HTML attribute as a string.

  • @param input_type: The input type to convert.
  • @return: The corresponding HTML attribute as a string. @example
let str = input_type_to_attribute(InputType.Text)
// str == "type=\"text\""
pub fn label(
  root root: Input,
  attributes attributes: Option(Attribute),
  innner inner: String,
) -> Input

This creates a string that represents a label element

  • @param root: The root of the element
  • @param attributes: The attributes of the element
  • @param inner: The child of the element
  • @returns: An Input
Search Document