Skip to content

Literal cannot be used as property/index accessor #331

@oformaniuk

Description

@oformaniuk

The following syntax is not correct for indexer accessor:

var source = "{{#each names}}{{@root.names.[@index]}}{{/each}}"; 
var data = new 
{ 
      names = new[] { "Foo", "Bar" }
}; 

Expected result: "FooBar"
Actual result: ""

As well as for property accessor:

var source = "{{#each enumerateMe}}{{ @root.enumerateMe.[@key] }} {{/each}}"; 
var data = new 
{ 
        enumerateMe = new Dictionary<string, object> 
        { 
             { "foo", "hello" }, 
             { "bar", "world" } 
        } 
};

Expected result: "hello world "
Actual result: "foo bar "

I've found similar behaviour described in handlebars-lang/handlebars.js/pull/569

If mentioned behaviour is expected I'd like to volunteer to create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions