Interpolation inside string inside quote

macro test()
  name="foo"
  quote
     "a string containing $name"
  end
end

On running this macro I would expect to receive “a string containing foo”. However all I get is UndefVarError: name not defined. How could I tell the macro that "$name" is to be double-expanded? (I tried a double dollar sign but this does not work either).

(By the way, that string is supposed to eventually be a docstring, if this has any impact on the solution).

You need another dollar sign:

julia> macro test()
         name="foo"
         quote
            "a string containing $($name)"
         end
       end
@test (macro with 1 method)

julia> @test()
"a string containing foo"

Because effectively

"a string containing $name" == "a string containing " * name

and

"a string containing $($name)" == "a string containing " * $name