Sneeze (sneeze v2.0.0)

Link to this section Summary

Functions

Render a data-structure, containing 'elements' to html. An element is either

Render a data-structure, containing 'elements' to an iodata list. This can be more performant than render/1 if you are passing the result to a function that takes iodata.

Link to this section Functions

Render a data-structure, containing 'elements' to html. An element is either:

  • [tag, attribute_map | body]

  • [tag, attribute_map]
  • [tag | body]

  • [tag]
  • [:@__raw_html, html_string]
  • [:script, attribute_map, script_text]
  • [:script, script_text]
  • [:style, attribute_map, style_text]
  • [:style, style_text]
  • A bare, stringable value (such as a string or number)
  • A list of elements

The content of :__@raw_html, :style and :script elements will not be escaped. All other elements content will be html-escaped.

Examples:

render([:p, %{class: "outlined"}, "hello"])
render([:br])
render([[:span, "one"], [:span, %{class: "highlight"}, "two"]])
render([:ul, %{id: "some-list"},
        [:li, [:a, %{href: "/"},      "Home"]],
        [:li, [:a, %{href: "/about"}, "About"]]])
render([:__@raw_html, "<!DOCTYPE html>"])
render([:script, "console.log(42 < 9);"])
Link to this function

render_iodata(data)

Render a data-structure, containing 'elements' to an iodata list. This can be more performant than render/1 if you are passing the result to a function that takes iodata.

Example:

render_iodata([:a, %{href: "example.com"}, "hello"])
# becomes...
[
  ["<", "a", [[" ", "href", "="", "example.com", """]], ">"],
  [["hello"]],
  ["</", "a", ">"]
]