Skip to content

Index inaccessible if using #input instead of #each input syntax? Issue with nested each #122

@aweintraut

Description

@aweintraut

My "Input" in this example is a list of a class called A (as returned by BuildTestData). Is there a way to access the index when using the alternate #Input syntax?

        [Theory]
        [InlineData("{{#each Input}}ii={{@index}} {{/each}}")] //Succeeds
        [InlineData("{{#Input}}ii={{@index}} {{/Input}}")] //Fails
        public void TestSingleLoopDictionary(string source)
        {
            var template = Handlebars.Compile(source);
            var data = new
            {
                Input = BuildTestData()
            };
            var result = template(data);
            Debug.WriteLine($"Source: {source}");
            Debug.WriteLine($"Result: {result}");
            Assert.Equal("ii=0 ii=1 ii=2 ", result);
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions