3 ms·
Do you know if the quote escape is still required with C# 6 interpolation?
by JBReefer 10y ago
Do you know if the quote escape is still required with C# 6 interpolation?
- Pxtl 10y agoC#6 string interpolation is glorious, but if you use the multiline var myString = $@" Hey, string interpolation is nifty. Look ma, no { this.Hands.ToString().ToUpper() } More text. But this is a ""quote"". It's ""ugly"" isn't it? "; As you can see, you need to double your double quotes to escape them. Almost perfect. You can even nest string interpolations to do next template stuff with functional-programming loops and whatnot.
- virtualwhys 10y agoScala seems to do what you want: val str = s""" Tripe quoted string interpolation Allows for $variables and ${method.foo(bar)} Mixed with "quotes" """ Can also use double quoted string interpolation for inline/one-liners where embedded quotes above aren't needed.
- insulanian 10y agoF# can have quotes inside triple-quoted string like Scala, sans interpolation.
- Pxtl 10y agoNeat! With facilities like that, Id be tempted to skip templating libraries altogether and just have a normal interface for templates and use the regular string expressions... Unless I needed then internationalized, and that's where Mustache shines, IMHO.