Skip to content

IndexOutOfRangeException in HandlebarsDotNet.PathStructure.PathResolver.ResolvePath for nested object path block expression #442

Description

@swijnands

Describe the bug

Trying to enumerate an array via a nested object path:

{{#bundles.styles.vendor}}{{this}}{{/bundles.styles.vendor}}

Results in an IndexOutOfRangeException exception.

Expected behavior:

I would expect the same result as when not using a nested path, i.e.

{{#arr}}....{/arr}}

Or, alternatively, if this is not supported: a clearer exception message.

Test to reproduce

varcontext=new{bundles=new{styles=new{vendor=new[]{"a","b","c"}}},arr=new[]{"d","e","f"}};// Works: Output = "abc"Handlebars.Compile("{{#each bundles.styles.vendor}}{{this}}{{/each}}")(context).Dump();// Works: Output = "def"Handlebars.Compile("{{#arr}}{{this}}{{/arr}}")(context).Dump();// Fails: IndexOutOfRangeException in HandlebarsDotNet.PathStructure.PathResolver.ResolvePath// On line #36: if (!TryResolveValue(pathInfo.IsVariable, context, pathChain[0], instance, out instance))Handlebars.Compile("{{#bundles.styles.vendor}}{{this}}{{/bundles.styles.vendor}}")(context).Dump();```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions