(no title)
kcartlidge | 6 months ago
string json = $"""
<h1>{title}</h1>
<article>
Welcome to {sitename}.
</article>
""";
And it even allows for using embedded curly braces as real characters: string json = $$"""
<h1>{{title}}</h1>
<article>
Welcome to {{sitename}}, which uses the <code>{sitename}</code> syntax.
</article>
""";
The $ (meaning to interpolate curly braces) appears twice, which switches interpolation to two curly braces, leaving the single ones untouched.
Metasyntactic|6 months ago
The indentation of the final ` """` line is what is removed from all other lines. Not the indentation of the first line. This allows the first line to be indented as well.
Cheers, and I'm glad you like it. I thought we did a really good job with that feature :-)
panzerboiler|6 months ago
gf000|6 months ago
winwang|6 months ago
Haven't used much C#, but I love Scala's `.stripPrefix` and `StringContext`.
kcartlidge|6 months ago