NLdoc.Conversion.Writer.Html.SimpleForm (NLdoc.Conversion.Writer.Html v1.2.26)

View Source

Module for HTML (SimpleForm) operations

Summary

Functions

Append attributes to existing tag.

Append child to existing tag.

Append children to existing tag.

Append child to existing tag.

Append attributes to existing tag.

Put children inside existing tag.

Create a new node with tag_name, attributes and children

Functions

append_attributes(node, new_attributes)

@spec append_attributes(
  node :: Floki.html_tag(),
  new_attributes :: [Floki.html_attribute()]
) ::
  Floki.html_tag()

Append attributes to existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.append_children([{"span", [], ["Other text"]}])
{"p", [{"class", "xyz"}], ["Some Text", {"span", [], ["Other text"]}]}

append_child(node, new_child)

@spec append_child(node :: Floki.html_tag(), new_child :: Floki.html_node()) ::
  Floki.html_tag()

Append child to existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.append_child({"span", [], ["Other text"]})
{"p", [{"class", "xyz"}], ["Some Text", {"span", [], ["Other text"]}]}

append_children(node, new_children)

@spec append_children(node :: Floki.html_tag(), new_children :: [Floki.html_node()]) ::
  Floki.html_tag()

Append children to existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.append_children([{"span", [], ["Other text"]}])
{"p", [{"class", "xyz"}], ["Some Text", {"span", [], ["Other text"]}]}

prepend_child(node, new_child)

@spec prepend_child(node :: Floki.html_tag(), new_child :: Floki.html_node()) ::
  Floki.html_tag()

Append child to existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.append_child({"span", [], ["Other text"]})
{"p", [{"class", "xyz"}], ["Some Text", {"span", [], ["Other text"]}]}

put_attributes(arg, new_attributes)

@spec put_attributes(node :: Floki.html_tag(), attributes :: [Floki.html_attribute()]) ::
  Floki.html_tag()

Append attributes to existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.append_children([{"span", [], ["Other text"]}])
{"p", [{"class", "xyz"}], ["Some Text", {"span", [], ["Other text"]}]}

put_children(arg, children)

@spec put_children(node :: Floki.html_tag(), children :: [Floki.html_node()]) ::
  Floki.html_tag()

Put children inside existing tag.

Examples

iex> { "p", [{"class", "xyz"}], ["Some Text"]}
...> |> NLdoc.Conversion.Writer.Html.SimpleForm.put_children([{"span", [], ["Other text"]}])
{"p", [{"class", "xyz"}], [{"span", [], ["Other text"]}]}

reverse(list)

@spec reverse(Floki.html_tag()) :: Floki.html_tag()
@spec reverse(Floki.html_node()) :: Floki.html_node()
@spec reverse([Floki.html_node()]) :: Floki.html_node()

tag(tag_name, attributes \\ [], children \\ [])

Create a new node with tag_name, attributes and children

Examples

iex> NLdoc.Conversion.Writer.Html.SimpleForm.tag("p", [{"class", "xyz"}], ["Some Text"])
{"p", [{"class", "xyz"}], ["Some Text"]}

iex> NLdoc.Conversion.Writer.Html.SimpleForm.tag("p", [{"class", "xyz"}])
{"p", [{"class", "xyz"}], []}

iex> NLdoc.Conversion.Writer.Html.SimpleForm.tag("p")
{"p", [], []}