View Source SimpleForm (SimpleForm v1.0.6)

SimpleForm provides a simple representation and manipulation of structured elements, similar to HTML or XML, using Elixir tuples and lists.

Overview

A SimpleForm.element() is represented as:

{tag_name, attributes, content}

Where:

  • tag_name is a string representing the name of the element.
  • attributes is a list of key-value tuples defining element attributes.
  • content is a list containing strings (text content) or nested elements.

Summary

Functions

Checks if value is an attribute.

Checks if value is content.

Checks if value is an element.

Types

attribute()

@type attribute() :: {key :: String.t(), value :: String.t()}

content()

@type content() :: [String.t() | element()]

element()

@type element() :: {tag_name(), [attribute()], content()}

tag_name()

@type tag_name() :: String.t()

Functions

attribute?(arg1)

@spec attribute?(value :: term()) :: boolean()

Checks if value is an attribute.

Examples

iex> SimpleForm.attribute?(true)
false
iex> SimpleForm.attribute?({"p", [{"class", "intro"}], [{"strong", [], ["Hello"]}, " world!"]})
false
iex> SimpleForm.attribute?({"class", "strong"})
true
iex> SimpleForm.attribute?("Hello World!")
false

content?(content)

@spec content?(value :: term()) :: boolean()

Checks if value is content.

Examples

iex> SimpleForm.content?(true)
false
iex> SimpleForm.content?({"p", [{"class", "intro"}], [{"strong", [], ["Hello"]}, " world!"]})
true
iex> SimpleForm.content?({"class", "strong"})
false
iex> SimpleForm.content?("Hello World!")
true

element?(arg1)

@spec element?(value :: term()) :: boolean()

Checks if value is an element.

Examples

iex> SimpleForm.element?(true)
false
iex> SimpleForm.element?({"p", [{"class", "intro"}], [{"strong", [], ["Hello"]}, " world!"]})
true
iex> SimpleForm.element?({"class", "strong"})
false
iex> SimpleForm.element?("Hello World!")
false