Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boolean changing to uppercase when running the template

sar-gup opened this issue · 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.

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