Materialize v0.1.4-dev Materialize.Html

Helper for create HTML blocks

Before add module

alias Elixir.Materialize.Html

Example

Create link a:

Elixir.Materialize.Html.get_a("Link", "#", [class: "example"])
Elixir.Materialize.Html.get_a [text: "Link", attr: [href: "#", class: "example"]]

result

<a href="#" class="example">Link</a>

Create tag span:

Elixir.Materialize.Html.get_tag("span", "Text", [class: "example"])
Elixir.Materialize.Html.get_tag [tag: "span", text: "Text", attr: [class: "example"]]

result

<span class="example">Text</span>

Create list ul:

Elixir.Materialize.Html.get_list [tag: "ul", attr: [class: "example"], items: [
  [text: "text"],
  [tag: "a", text: "link", attr: [href: "#"]]
]]

result

<ul>
  <li>text</li>
  <li><a href="#">link</a></li>
</ul>

Summary

Functions

Create link a

Get html attributes

Create list ul

Create tag span or etc

Create tag span or etc

Check if key exists and value is not empty

Functions

get_a(item)
get_a(Keyword.t) :: List.t

Create link a

Parameters

  • item: keyword list

Example

Elixir.Materialize.Html.get_a [text: "Link", attr: [href: "#", class: "example"]]
get_a(text, href, attr \\ [])

Create link a

Parameters

  • text: text link
  • href: ulr link
  • attr: keyword list

Example

Elixir.Materialize.Html.get_a("Link", "#", [class: "example"])
get_attribute(item)
get_attribute(Keyword.t) :: List.t

Get html attributes

Parameters

  • item: keyword list

Example

Elixir.Materialize.Html.get_attribute [tag: "span", text: "Text", attr: [id: "abc", class: "example"]]

Result

id="abc" class="example"
get_list(item)
get_list(Keyword.t) :: List.t

Create list ul

Parameters

  • item: keyword list

Example

Elixir.Materialize.Html.get_list [tag: "ul", attr: [class: "example"], items: [
  [text: "text"],
  [tag: "a", text: "link", attr: [href: "#"]]
]]
get_tag(item)
get_tag(Keyword.t) :: List.t

Create tag span or etc.

Parameters

  • item: keyword list

Example

Elixir.Materialize.Html.get_tag [tag: "span", text: "Text", attr: [class: "example"]]
get_tag(tag, text, attr \\ [])

Create tag span or etc.

Parameters

  • tag: tag, span, i, p … etc.
  • text: text into tag
  • attr: keyword list html attributes

Example

Elixir.Materialize.Html.get_tag("span", "Text", [class: "example"])
has_key?(item, attr)
has_key?(Keyword.t, Atom.t) :: boolean

Check if key exists and value is not empty

Parameters

  • item: keyword list
  • attr: atom

Example

Elixir.Materialize.Html.has_key?([tag: "span", text: "Text", attr: [class: "example"]], :attr)