I saw this post and I tried to use a macro that returns a string combining the value extracted from a structure and something else but it didn’t work, something like:
defmacro return_string(some_struct) do
quote do: "#id-{unquote(some_struct).id}"
end
It’s a bit weird because the returning value is a string but for some reason the compiler checks that is not right. My guess is that the interpolation happens after the evaluation and the compiler is unhappy because it doesn’t know what to expect. Just a guess!
Right! It’s a reference to a table not to an struct. Thanks for pointing that out. I tested using a fragment as you suggested and it worked great. Thanks for your comment @al2o3cr.