View Source Pile (pile v0.2.0)
Introduction
This library provides a way to convert plain Elixir data structures into HTML.
iex> data = [
...> doctype!: %{html: true},
...> html: [
...> head: [
...> title: "Hello World"
...> ]
...> ]
...> ]
iex> Pile.to_html(data)
"<doctype! html><html><head><title>Hello World</title></head></html>"
See Pile.to_html/2
for details about shape of data structure
Summary
Functions
Creates a CSS ruleset that can be attached as an attribute to an HTML element
Converts an Elixir keyword list into to an HTML string
Functions
Creates a CSS ruleset that can be attached as an attribute to an HTML element
Converts an Elixir keyword list into to an HTML string
Options:
pretty
: Passingtrue
causes the HTML output to be pretty-printed. Defaults tofalse
Input structure:
Keys represents HTML elements and values represents their children.
iex> Pile.to_html([div: [p: ["hello"]]])
"<div><p>hello</p></div>"
If an element only has one text child, you do not need to put it in a list
iex> Pile.to_html([div: [p: "hello"]])
"<div><p>hello</p></div>"
Attributes are represented as a map at the start of a list:
iex> Pile.to_html([div: [%{class: "container"}, p: "hello"]])
"<div class=\"container\"><p>hello</p></div>"
If an element has attributes, but not children, you do not need to put it in a list
iex> Pile.to_html([div: %{class: "container"}])
"<div class=\"container\"></div>"