You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexOutOfRangeException in HandlebarsDotNet.PathStructure.PathResolver.ResolvePath for nested object path block expression #442
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();```
@aslezak , it's hard to tell without testing. I'd really appreciate if you can have a look closer.
nit: Try to avoid Linq as this is performance critical path. In this case the check can be placed inside of for that is right below the line you mentioned.
Activity
oformaniuk commentedon Mar 24, 2021
This should definitely be supported.
Looks like something weird is happening when we're trying to resolve an actual array to enumerate on.
sushantduggal commentedon Jun 29, 2021
Facing the same issue, is there a resolution on this?
devzaak commentedon Aug 27, 2021
I am not 100% sure but this could be a fix for issue:
In: PathResolver.cs
replacing
with
I am unsure if this will cause other problems though as I am not familiar with lib yet.
oformaniuk commentedon Aug 27, 2021
@aslezak , it's hard to tell without testing. I'd really appreciate if you can have a look closer.
nit: Try to avoid Linq as this is performance critical path. In this case the check can be placed inside of
forthat is right below the line you mentioned.devzaak commentedon Sep 1, 2021
Will do as soon as I have some spare time, and yes, I noticed I can do continue; in the loop instead of prefiltering them.
Enable support for chained path iterators
abraham-fox commentedon Jan 23, 2022
No updates for 5 month - I assume I can grab this :) and it seems I've found a simple solution for the issue. @zjklee please take a look at #488.