Skip to content

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

Closed

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

  1. jknack commented on Aug 14, 2026

    @jknack
    Owner

    yes, looks like a regression

  2. added this to the 4.5.5 milestone on Aug 14, 2026
  3. jonathan-yan commented on Aug 17, 2026

    @jonathan-yan
    Author

    Thank you @jknack for looking into this issue and fixing it so quickly.

  4. added a commit that references this issue on Oct 12, 2026
    ef656ec
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions