Handlebars.Net icon indicating copy to clipboard operation
Handlebars.Net copied to clipboard

Boolean changing to uppercase when running the template

Open sar-gup opened this issue 2 years ago • 1 comments

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.

sar-gup avatar Sep 28 '23 17:09 sar-gup

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

Nisden avatar Oct 24 '23 16:10 Nisden