Icons correctly implement Phoenix.HTML.Safe

This commit is contained in:
Max Veytsman
2021-03-10 14:30:12 -05:00
parent 4e43e7323a
commit df8fe650e7
5 changed files with 39 additions and 18 deletions

View File

@ -48,11 +48,8 @@ defmodule Heroicons do
@doc unquote(doc)
@spec unquote(name)(keyword(binary)) :: binary
def unquote(name)(opts \\ []) do
attrs =
opts
|> Enum.map_join(fn {k, v} -> ~s( #{k}="#{v}") end)
unquote(head) <> attrs <> unquote(tail)
attrs = for {k, v} <- opts, do: {:safe, [Phoenix.HTML.Safe.to_iodata(k), ?=, ?", Phoenix.HTML.Safe.to_iodata(v), ?"]}
{:safe, [unquote(head), Phoenix.HTML.Safe.to_iodata(attrs), unquote(tail)]}
end
end
end