Skip to content

HandleBars.Compile replaces '\\' (double backslash) with '\' single backslash #462

@bascoder

Description

@bascoder

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 = @"\\\\".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions