Hmm, I think sigil_p/2 pattern matches against ast and unquoting that expression results in fully evaluated binary.
I bet there would be a more intuitive solution but this works:
defmodule A do
defmacro __using__(opts) do
path = opts[:path]
quote do
use Phoenix.Component
def handle_event("event", _, socket) do
path = sigil_p(unquote({:<<>>, _meta = [], ["/#{path}"]}), [])
# ...
{:noreply, socket}
end
end
end
end
defmodule B do
use A, path: "my-path"
end
warning: no route path for InformedCMSWeb.Router matches "/my-path"
iex:112: B.handle_event/3
So I passed the simplified version of desired ast:
iex> quote(do: "/#{path}")
{:<<>>, [],
[
"/",
{:"::", [],
[
{{:., [], [Kernel, :to_string]}, [], [{:path, [], Elixir}]},
{:binary, [], Elixir}
]}
]}






















