diff --git a/lib/temple/form.ex b/lib/temple/form.ex index fe2d68c..c31553a 100644 --- a/lib/temple/form.ex +++ b/lib/temple/form.ex @@ -117,12 +117,7 @@ defmodule Temple.Form do """ defmacro submit(do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, input} = Phoenix.HTML.Form.submit(do: content) + {:safe, input} = Phoenix.HTML.Form.submit(do: temple(do: unquote(block))) Utils.put_buffer(var!(buff, Temple.Tags), input) end @@ -141,12 +136,7 @@ defmodule Temple.Form do """ defmacro submit(opts, do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, input} = Phoenix.HTML.Form.submit(unquote(opts), do: content) + {:safe, input} = Phoenix.HTML.Form.submit(unquote(opts), do: temple(do: unquote(block))) Utils.put_buffer(var!(buff, Temple.Tags), input) end @@ -176,12 +166,8 @@ defmodule Temple.Form do """ defmacro phx_label(form, field, do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, input} = Phoenix.HTML.Form.label(unquote_splicing([form, field]), do: content) + {:safe, input} = + Phoenix.HTML.Form.label(unquote_splicing([form, field]), do: temple(do: unquote(block))) Utils.put_buffer(var!(buff, Temple.Tags), input) end @@ -200,12 +186,10 @@ defmodule Temple.Form do """ defmacro phx_label(form, field, opts, do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, input} = Phoenix.HTML.Form.label(unquote_splicing([form, field, opts]), do: content) + {:safe, input} = + Phoenix.HTML.Form.label(unquote_splicing([form, field, opts]), + do: temple(do: unquote(block)) + ) Utils.put_buffer(var!(buff, Temple.Tags), input) end diff --git a/lib/temple/link.ex b/lib/temple/link.ex index 596c5c7..4d13639 100644 --- a/lib/temple/link.ex +++ b/lib/temple/link.ex @@ -11,12 +11,9 @@ defmodule Temple.Link do """ defmacro phx_link(opts, do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, link} = HTML.Link.link(content, unquote(opts)) + {:safe, link} = + temple(do: unquote(block)) + |> HTML.Link.link(unquote(opts)) Utils.put_buffer(var!(buff, Temple.Tags), link) end @@ -35,12 +32,7 @@ defmodule Temple.Link do """ defmacro phx_button(opts, do: block) do quote location: :keep do - {:safe, content} = - temple do - unquote(block) - end - - {:safe, link} = HTML.Link.button(content, unquote(opts)) + {:safe, link} = HTML.Link.button(temple(do: unquote(block)), unquote(opts)) Utils.put_buffer(var!(buff, Temple.Tags), link) end diff --git a/test/temple/link_test.exs b/test/temple/link_test.exs index f097557..f70f868 100644 --- a/test/temple/link_test.exs +++ b/test/temple/link_test.exs @@ -40,9 +40,9 @@ defmodule Temple.LinkTest do assert String.starts_with?(actual, ~s{
} assert actual =~ ~s{hi} - assert actual =~ ~s{</div></div>} + assert actual =~ ~s{
} assert String.ends_with?(actual, ~s{}) end @@ -124,9 +124,9 @@ defmodule Temple.LinkTest do assert String.starts_with?(actual, ~s{
} assert actual =~ ~s{hi} - assert actual =~ ~s{</div></div>} + assert actual =~ ~s{
} assert String.ends_with?(actual, ~s{}) end