Skip to content

Iteration variables no longer visible in partial called from an each block #1185

Description

@jonathan-yan

Since version 4.5.2, the following test has started failing:

@Test
public void shouldResolveIterationVariablesInPartial() throws IOException {
    Handlebars handlebars = new Handlebars();
    Template template = handlebars.compileInline("{{#each items}}{{> myPartial}}{{/each}}");
    Map<String, Object> model = new HashMap<>();
    model.put("items", new String[]{"Item 1"});

    String result = template.apply(Context.newBuilder(model).build());

    assertEquals("@index: 0, @first: first, @last: last\n", result);
}

where myPartial.hbs is as follows:

@index: {{@index}}, @first: {{@first}}, @last: {{@last}}

Is this a regression?

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

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions