Duplo v0.1.1 Duplo.Tag View Source
Defines tag rendering function inside of a module for convenience. Intended to be used with a list of atom as function to define
## Example
defmodule Module do
use Duplo.Tag, [:div, :span] # Defines div/2 and span/2
end
iex> TagTest.Module.div(class: "button")
"<div class=\"button\"></div>"
iex> TagTest.Module.span(class: "button")
"<span class=\"button\"></span>"
Link to this section Summary
Functions
Format a list of attributes to be output in HTML. It dashes the key ("HelloWorld" key becomes "hello-world") and sanitize the value
Renders children, you can either give a string or a list of string
Render a specific tag with given attrs and children
Link to this section Functions
Link to this function
render_attributes(attrs) View Source
Format a list of attributes to be output in HTML. It dashes the key ("HelloWorld" key becomes "hello-world") and sanitize the value
## Examples
iex> Duplo.Tag.render_attributes([class: "btn btn-xs btn-primary"])
"class=\"btn btn-xs btn-primary\""
Link to this function
render_children(children) View Source
Renders children, you can either give a string or a list of string
## Examples
iex> Duplo.Tag.render_children("A text")
"A text"
iex> Duplo.Tag.render_children(["A text", "And another one"])
"A textAnd another one"
Link to this function
render_tag(tag) View Source
Render a specific tag with given attrs and children
## Example
iex> Duplo.Tag.render_tag("master-tag", [special_attr: "A value"], ["Child"])
"<master-tag special-attr=\"A value\">Child</master-tag>"
Link to this function
render_tag(tag, attrs) View Source
Link to this function