Taggart v0.1.5 Taggart.Tags View Source
Define HTML tags.
Contains macros for creating a tag-based DSL.
Link to this section Summary
Link to this section Functions
Define a new tag.
deftag :span
deftag :div
div do
span("Foo")
end
Define a new void tag.
deftag :hr, void: true
deftag :img, void: true
hr()
img(class: "red")
See taggart/1
Allows grouping tags in a block.
Groups tags such that they all become part of the result. Normally,
with an Elixir block, only the last expression is part of the value.
This is useful, for example, as the do block of
Phoenix.HTML.Form.form_for/4
.
form_for(conn, "/users", [as: :user], fn f ->
taggart do
label do
"Name:"
text_input(f, :name)
end
label do
"Age:"
select(f, :age, 18..100)
end
end
end
Examples
iex> taggart() |> Phoenix.HTML.safe_to_string()
""
iex> (taggart do div() ; span() end) |> Phoenix.HTML.safe_to_string()
"<div></div><span></span>"