Created
September 20, 2013 18:16
-
-
Save matheusca/6641567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Weber.Helper.Html do | |
def tag(html_tag, content, input_html // []) do | |
initial_tag = create_initial_tag(html_tag, input_html) | |
end_tag = create_end_tag(html_tag) | |
"#{initial_tag}#{content}#{end_tag}" | |
end | |
defp create_initial_tag(html_tag, input_html) do | |
"<#{html_tag}#{generate_input_html(input_html)}" | |
end | |
defp generate_input_html([]) do | |
">" | |
end | |
defp generate_input_html([tail | head]) do | |
{tag_html, value} = tail | |
" #{tag_html}=\"#{value}\"#{generate_input_html(head)}" | |
end | |
defp create_end_tag(html_tag) do | |
"</#{html_tag}>" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment