Skip to content

Escaping of keys does not work with . characters #328

@alexdawes

Description

@alexdawes

When a key has a . in, handlebars.net fails to find the key, even when escaping with [...]

using System;
using HandlebarsDotNet;
using Newtonsoft.Json.Linq;

namespace HandlebarsTester
{
    public static class Program
    {
        internal static string Test(string template, string json)
        {
            var jObject = JObject.Parse(json);
            var compiled = Handlebars.Compile(template);
            var result = compiled.Invoke(jObject);
            return result;
        }

        public static void Main(string[] args)
        {
            Console.WriteLine(Test("foo.bar: {{ [foo.bar] }}", "{ \"foo.bar\": \"FOO\" }"));
            Console.ReadLine();
        }
    }
}

The above example prints: foo.bar: . The equivalent using handlebarsjs successfully renders this as foo.bar: FOO

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions