Skip to content

Commit bf2925d

Browse files
authored
Merge pull request #488 from abraham-fox/enable-support-for-chained-path-iterators
Enable support for chained path iterators
2 parents 4277ab1 + 370a3a6 commit bf2925d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

source/Handlebars.Test/BasicIntegrationTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,6 +2044,25 @@ public void HtmlEncoderCompatibilityIntegration_LateChangeConfig(bool useLegacyH
20442044

20452045
Assert.Equal(expected, actual);
20462046
}
2047+
2048+
[Fact]
2049+
public void ChainedPathIteratorHelper()
2050+
{
2051+
var context = new
2052+
{
2053+
bundles = new
2054+
{
2055+
styles = new
2056+
{
2057+
vendor = new[] { "a", "b", "c" }
2058+
}
2059+
}
2060+
};
2061+
2062+
var nestedObjectsHelperResult = Handlebars.Compile("{{#bundles.styles.vendor}}{{this}}{{/bundles.styles.vendor}}")(context);
2063+
2064+
Assert.Equal("abc", nestedObjectsHelperResult);
2065+
}
20472066

20482067
private class StringHelperResolver : IHelperResolver
20492068
{

source/Handlebars/PathStructure/PathInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public static PathInfo Parse(string path)
189189
}
190190

191191
var chainSegments = GetPathChain(segment);
192-
if (chainSegments.Length > 1) isValidHelperLiteral = false;
192+
193+
if (chainSegments.Length > 1 && pathType != PathType.BlockHelper) isValidHelperLiteral = false;
193194

194195
segments.Add(new PathSegment(segment, chainSegments));
195196
}

0 commit comments

Comments
 (0)