ratchet v0.0.3 Ratchet.Html

Summary

Functions

Apply content to an element

Get the property from a list

Transform an element with data

Transform a particular scope in the view with data

Functions

apply(element, content)

Apply content to an element

iex> Html.apply({"div", [], []}, "Content")
{"div", [], ["Content"]}

iex> Html.apply({"p", [], []}, ["one", "two"])
[{"p", [], ["one"]}, {"p", [], ["two"]}]
get_property(attributes)

Get the property from a list

iex> Html.get_property([:foo, :bar, {"data-prop", "wow"}])
{:ok, "wow"}
iex> Html.get_property([:foo, :bar, :baz])
:error
transform(element, data)

Transform an element with data

iex> Html.transform({"div", [], [{"p", [{"data-prop", "body"}], []}]}, %{"body" => "Hi!"})
{"div", [], [{"p", [{"data-prop", "body"}], ["Hi!"]}]}
transform(element, scope, data)

Transform a particular scope in the view with data

iex> Html.transform({"div", [], [{"p", [{"data-scope", "para"}, {"data-prop", "body"}], []}]}, "para", %{"body" => "Hi!"})
{"div", [], [{"p", [{"data-scope", "para"}, {"data-prop", "body"}], ["Hi!"]}]}