marker v2.0.0 Marker.Element

This module is responsible for generating element macro’s. Marker generates by default all html5 elements, but you can easily generate other elements too:

defmodule MyElements do
  use Marker.Element, tags: [:my_element, :another_one]
end

You can now use your custom elements like the default elements:

use MyElements

my_element id: 42 do
  another_one "Hello world"
end

Which will result in:

{:safe, "<my_element id='42'><another_one>Hello world</another_one></my_element>"}

Casing

You can control the casing of the generated elements too:

defmodule MyElements do
  use Marker.Element, casing: :camel, tags: [:my_element, :another_one]
end

my_element id: 42 do
  another_one "Hello world"
end

{:safe, "<myElement id='42'><anotherOne>Hello world</anotherOne></myElement>"}

The following casing options are allowed:

  • :snake => my_element (default)
  • :snake_upcase => MY_ELEMENT
  • :pascal => MyElement
  • :camel => myElement
  • :lisp => my-element
  • :lisp_upcase => MY-ELEMENT

Summary

Types

attr_name :: atom
t :: %Marker.Element{attrs: attrs, content: Marker.content, tag: atom}