Skip to content

Commit 4e4b5dd

Browse files
committed
Template String: Change interpolation to remove '$' sign
1 parent 5ebb3d4 commit 4e4b5dd

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,8 @@ Token ReadTemplateString(int fromLine, int fromCol, bool isStart)
646646
goto redo_Loop;
647647
}
648648
}
649-
else if (c == '$' && CursorMatches("${"))
649+
else if (c == '{')
650650
{
651-
CursorCharNext();
652651
CursorCharNext();
653652
Token t = CreateToken(TokenType.String_TemplateFragment, fromLine, fromCol);
654653
t.Text = LexerUtils.UnescapeLuaString(t, text.ToString());

src/MoonSharp.Tests/EndToEnd/CSyntaxTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public void LengthPropertyReadonly()
441441
[Test]
442442
public void NestedStringTemplate()
443443
{
444-
TestScript.Run(@"assert.areequal('hello', ``${``hello``}``);", s => s.Options.Syntax = ScriptSyntax.CLike);
444+
TestScript.Run(@"assert.areequal('hello', ``{``hello``}``);", s => s.Options.Syntax = ScriptSyntax.CLike);
445445
}
446446

447447
[Test]
@@ -454,14 +454,14 @@ public void EscapeStringTemplate()
454454
public void StringTemplate()
455455
{
456456
TestScript.Run(@"
457-
assert.areequal('3', ``${3}``);
457+
assert.areequal('3', ``{3}``);
458458
function getFirst(tbl) { return tbl[1]; }
459-
assert.areequal('hello', ``${ //4
459+
assert.areequal('hello', ``{ //4
460460
getFirst({ //5
461461
'hello' //6
462462
}) //7
463463
}``);
464-
assert.areequal('hello world', ``${'hello'} ${'world'}``);
464+
assert.areequal('hello world', ``{'hello'} {'world'}``);
465465
", s => s.Options.Syntax = ScriptSyntax.CLike);
466466
}
467467

0 commit comments

Comments
 (0)