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

The first parameter match/unmatch will overwrite all the subsequent same-spelling match/unmatch

Open Ellaluo opened this issue 4 years ago • 1 comments

The case-sensitive matching works well when there is only one variable of one spelling. When there are multiple variables of same spelling but different upper/lower cases, things get messged up. For example:

var templateString = "Example {{TEST}} {{test}} | {{test2}} | {{TEST3}} {{test3}} | {{TesT}}";
var template = Handlebars.Compile(templateString);
var data = new ExpandoObject();
data.TryAdd("TEST", "Upper");
data.TryAdd("test", "Lower");
data.TryAdd("test2", "Lower2");
data.TryAdd("test3", "Lower3");
data.TryAdd("TesT", "Last");

var output = template(data);

Console.WriteLine(output);

prints

Example Upper Upper | Lower2 | | Upper.

If I use Handlebars.js, it prints

Example Upper Lower | Lower2 | Lower3 | Last.

It looks like the first match/unmatch, messed up all the subsequent same-spelling match.

Ellaluo avatar Mar 10 '21 10:03 Ellaluo

Related to https://github.com/Handlebars-Net/Handlebars.Net/issues/362

Additional fix is required to get same behavior as in Handlebarsjs. Dynamic and Reflection accessors have the same problem.

oformaniuk avatar Mar 11 '21 11:03 oformaniuk