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

Can't Reference Capitalized Hashtable Elements

Open AceCoderLaura opened this issue 3 years ago • 2 comments

Attempting to reference a Hashtable element with a key containing an uppercase letter will fail. Dictionaries however work fine.

Example:

using System.Collections;
using HandlebarsDotNet;

const string template = @"Hello {{ NAME }}, have a nice day.";

var compiledTemplate = Handlebars.Compile(template);

var notWorkingOutput = compiledTemplate(new Hashtable
{
    { "NAME", "bob" }
});

var workingOutput = compiledTemplate(new Dictionary<string,string>()
{
    { "NAME", "alice" }
});

Console.WriteLine(workingOutput);
Console.WriteLine(notWorkingOutput);

AceCoderLaura avatar Jun 22 '22 00:06 AceCoderLaura

What happens with a HashTable element with a lowercase key?

rexm avatar Jun 22 '22 01:06 rexm

If you use a lowercase key in the Hashtable you can reference it with any casing from the template.

AceCoderLaura avatar Aug 30 '22 06:08 AceCoderLaura