Skip to content

generate html in elixir with simple data structures

License

Notifications You must be signed in to change notification settings

camshaft/html_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html_builder Build Status

generate html in elixir with simple data structures

Installation

Firs, add HTMLBuilder to your mix.exs dependencies:

def deps do
  [{:html_builder, "~> 0.1"}]
end

Then, update your dependencies:

$ mix deps.get

Usage

{:html, [
  {:__comment__, "This is a test"},
  {"head", nil, [
    {"title", nil, "Hello!"},
    {"meta", name: :description, content: "Hello!"}
  ]},
  {"body", nil, [
    {"span", [class: "this-is-a-class\" other classes go here"], "This is a test"},
    {"span", class: "attribute-with-¨˜ˆçø"},
    {"span", nil, [
      "Hello,",
      "World",
      {"ul", nil, for n <- 1..3 do
        {"li", nil, [
          {"span", nil, n},
          ":",
          {"span", nil, n * n}
        ]}
      end}
    ]}
  ]}
]} |> HTMLBuilder.encode!(pretty: true) |> IO.puts

# <!DOCTYPE html>
# <html>
# <!-- This is a test -->
# <head>
#   <title>Hello!</title>
#   <meta name=description content=Hello!>
# </head>
# <body>
#   <span class="this-is-a-class&quot; other classes go here">This is a test</span>
#   <span class=attribute-with-¨˜ˆçø></span>
#   <span>
#     Hello,
#     World
#     <ul>
#       <li>
#         <span>1</span>
#         :
#         <span>1</span>
#       </li>
#       <li>
#         <span>2</span>
#         :
#         <span>4</span>
#       </li>
#       <li>
#         <span>3</span>
#         :
#         <span>9</span>
#       </li>
#     </ul>
#   </span>
# </body>
# </html>

About

generate html in elixir with simple data structures

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages