DslHtml
DSL for HTML in Elixir.
NOTE
This code is based from the sample code in below book:
If you want to find more, check it out.
Installation
If available in Hex, the package can be installed as:
-
Add
dsl_htmlto your list of dependencies inmix.exs:
```elixir
def deps do
[{:dsl_html, "~> 0.1.0"}]
end
```-
Ensure
dsl_htmlis started before your application:
```elixir
def application do
[applications: [:dsl_html]]
end
```Usage
defmodule Template do
import Html
def render do
markup do
div id: "main" do
h1 class: "title" do
text "Welcome!"
end
end
div class: "row" do
div do
p do: text "Hello!"
end
end
table do
tr do
for i <- 0..5 do
td do: text("Cell #{i}")
end
end
end
div do
text "Some Nested Content"
end
end
end
end