Taggart v0.1.0 Taggart View Source

Generates tags upon use.

The use macro automatically handles any ambiguities between html elements and the funcions from Kernel. Kernel.div/2 for example is unimported to allow the use of the div element. If you still need to use Kernel.div/2, just call it as Kernel.div(20, 2)

Importing

Generates all known HTML tags as macros upon import:

use Taggart

div do
  span("some content")
end

Generates just the given tags:

use Taggart, tags: [:foo, :bar]

foo do
  bar("some content")
end

If you would like to carefully control the imports:

import Kernel, except: [div: 2]
use Taggart, deconflict_imports: false

Link to this section Summary

Functions

Allows grouping tags in a block

Link to this section Functions

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>"