Skip to content

Commit

Permalink
Add string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Oziomek committed Sep 2, 2023
1 parent 863efc0 commit f36357b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
@@ -1 +1,7 @@
Scriban 5.8 can interpolate strings now
Nested interpolation: 23new string
UPPERCASE: 14
UPPERCASE: 14
Little more complex example: 2 Scriban 5
Interpolation at the beginning: 4 is 4
Pure string
@@ -1 +1,7 @@
{{ $"Scriban {4 + 1}.8 can interpolate strings now" }}
{{ $"Nested interpolation: {23 + "new string"}" }}
{{ $"Uppercase: {4 + 10}" | string.upcase }}
{{ string.upcase $"Uppercase: {4 + 10}" }}
{{ $'Little more complex example: {2 + " " + string.capitalize $"scriban {5}"}' }}
Interpolation at the beginning: {{ $"{math.times 2 2} is 4" }}
{{ $"Pure string" }}
2 changes: 1 addition & 1 deletion src/Scriban/Syntax/Expressions/ScriptLiteral.cs
Expand Up @@ -183,7 +183,7 @@ private static string ToLiteral(ScriptLiteralStringQuoteType quoteType, TokenTyp

var literal = new StringBuilder(input.Length + 2);

if (interpolated)
if (interpolated && stringTokenType != TokenType.ContinuationInterpString && stringTokenType != TokenType.EndingInterpString)
{
literal.Capacity = input.Length + 3;
literal.Append('$');
Expand Down

0 comments on commit f36357b

Please sign in to comment.