Skip to content

Commit

Permalink
fixes #290
Browse files Browse the repository at this point in the history
  • Loading branch information
kmvi committed Aug 25, 2023
1 parent 97cb9ce commit 9981382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions NiL.JS/Expressions/TemplateString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static Expression Parse(ParseInfo state, ref int index, TemplateStringMod
if (state.Code[pos] == '$')
{
pos += 2;
Tools.SkipSpaces(state.Code, ref pos);
expressions.Add((Expression)ExpressionTree.Parse(state, ref pos));

Tools.SkipSpaces(state.Code, ref pos);
Expand Down
12 changes: 12 additions & 0 deletions Tests/StringInterpolationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,17 @@ public void StringInterpolationAllowsSubstititions()

Assert.AreEqual("This is a string such as 1234", stringValue.Value);
}

[TestMethod]
public void StringInterpolationAllowsWhitespaces()
{
var context = new Context();
var code = @"var a=1234; `This is a string such as ${
a }`";
var stringValue = context.Eval(code);

Assert.AreEqual("This is a string such as 1234", stringValue.Value);
}
}
}

0 comments on commit 9981382

Please sign in to comment.