udoprog / genco

A whitespace-aware quasiquoter for beautiful code generation.
Apache License 2.0
181 stars 11 forks source link

Interpolate string variable without quotes #35

Closed danielblignaut closed 1 year ago

danielblignaut commented 1 year ago

Hi,

Is there a way to render the contents of a rust variables (which is a String type) but without the surrounding quotes? Similar to if I just had

quote! {
raw_value
}

would output: raw_value ... I'm looking for

let custom_variable: String = "raw_value"
quote! {
#custom_variable
}

would also output: raw_value where

I've tried all sort of String to static string conversions, attempted implementing my own language but just can't get it to work.

udoprog commented 1 year ago

Interpolation in genco is done with $ since #27, so try $custom_variable!

danielblignaut commented 1 year ago

Hi @udoprog ,

So I have the interpolation working in both v16 and v17 (changing # for $). But the interpolated string has quotes generated around it when it's outputted. I am trying to avoid the quotes being added. Is this possible?

udoprog commented 1 year ago

Hm, so I'm not following. This works for me: https://github.com/udoprog/genco/commit/885f5bad44d7eef86a47310f9fa4b738b47708f8

What exactly are you doing?