Actually I would avoid using here __using__ as it is not necessary. I would something like this:
defmodule Attributes do
defmacro generic_attributes() do
quote do
attr :class, :string, default: ""
attr :id, :string, default: nil
attr :rest, :global
end
end
end
And using it inside of components by:
require Attributes
Attributes.generic_attributes()
The advantages are:
- Much more readability, as you can document the macro and have a clear understanding where you use it, opposed to use;
- Macro defined in this way can only inject code, to avoid people coming later and adding their “smart” ideas.






















