Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't Reference Capitalized Hashtable Elements

AceCoderLaura opened this issue · comments

commented

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);

What happens with a HashTable element with a lowercase key?

commented

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