Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.22k stars 213 forks source link

Boolean changing to uppercase when running the template #557

Closed sar-gup closed 3 months ago

sar-gup commented 10 months ago

Describe the bug

For template: { "more": {{ mybool }} }

and input param Dictionary<string, object> { {"mybool", true}},

the result is: { "more": True }

The upper case conversion to True is not expected.

Expected behavior:

true should be in lowercase { "more": true }

Test to reproduce

[Fact]
public void Descriptive_Test_Name_Here()
{
    var handlebars = Handlebars.Create();
    var render = handlebars.Compile("{{input}}");
    object data = new { input = 42 };

    var actual = render(data);
    Assert.Equal(42, actual);
}

Other related info

Provide additional information if any.


After submitting the issue

Please consider contributing to the project by submitting a PR with a fix to the issue. This would help to solve your problem in a shorter time as well as help other users of the project.

In case you do not know where to start - feel free to ask for help in the issue thread.

Building an active community is essential for any project survival as time of maintainers is limited.

Nisden commented 9 months ago

If you look at the documentation for .NET, the string value of a boolean is actually "True"
See https://learn.microsoft.com/en-us/dotnet/api/system.boolean.truestring?view=net-7.0

So the current behavior is correct