Load icon into function directly
This commit is contained in:
@ -31,6 +31,11 @@ defmodule Heroicons do
|
|||||||
|> String.replace("-", "_")
|
|> String.replace("-", "_")
|
||||||
|> String.to_atom()
|
|> String.to_atom()
|
||||||
|
|
||||||
|
icon = File.read!(path)
|
||||||
|
{i, _} = :binary.match(icon, ">")
|
||||||
|
|
||||||
|
{head, tail} = String.split_at(icon, i)
|
||||||
|
|
||||||
doc = """
|
doc = """
|
||||||
)}) {: width=24px}
|
)}) {: width=24px}
|
||||||
|
|
||||||
@ -43,16 +48,11 @@ defmodule Heroicons do
|
|||||||
@doc unquote(doc)
|
@doc unquote(doc)
|
||||||
@spec unquote(name)(keyword(binary)) :: binary
|
@spec unquote(name)(keyword(binary)) :: binary
|
||||||
def unquote(name)(opts \\ []) do
|
def unquote(name)(opts \\ []) do
|
||||||
icon = File.read!(unquote(path))
|
|
||||||
{i, _} = :binary.match(icon, ">")
|
|
||||||
|
|
||||||
{head, tail} = String.split_at(icon, i)
|
|
||||||
|
|
||||||
attrs =
|
attrs =
|
||||||
opts
|
opts
|
||||||
|> Enum.map_join(fn {k, v} -> ~s( #{k}="#{v}") end)
|
|> Enum.map_join(fn {k, v} -> ~s( #{k}="#{v}") end)
|
||||||
|
|
||||||
head <> attrs <> tail
|
unquote(head) <> attrs <> unquote(tail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user