HandleBars.Compile replaces '\\' (double backslash) with '\' single backslash
bascoder opened this issue · 4 comments
What
When the template contains a double backslash. The result only contains a single backslash.
Reproduction
To reproduce I wrote the following unit test:
[TestMethod]
public void Compile_WithDoubleBackslashes_ReturnsExpectedString()
{
string template = @"\\";
var compiledTemplate = Handlebars.Compile(template);
string result = compiledTemplate(null);
Assert.AreEqual(@"\\", result);
}
It fails with message:
Assert.AreEqual failed. Expected:<\\>. Actual:<\>.
Here I would expect that the result string contains the double backslash.
Workaround
To workaround this issue I can change the template to string template = @"\\\\"
.
Duplicate/related: #349
May be considered as a breaking change as this was the behavior from the day one and many users may be impacted.
Fix may require feature flag to switch to new behavior (or to previous behavior, up to the contributor).
#348
-- may be used as a starting point for the fix.
Hello @xcskilab
Can you provide more details on your question as I'm not completely sure what context you're asking in?