Skip to content

Certain helpers don't work inside parameterised blocks #1183

Description

@swg-bsi

Upon upgrading from 4.5.1 to 4.5.2 certain templates started to break/behave in unexpected ways. In particular constructs like the following break now:

Definition of the handlebars helper:

handlebars.registerHelper("test.helper", new Helper<String>() {
    @Override
    public Object apply(String text, Options options) {
        return "Hello " + text;
    }
});

Usage:

{{#each names as |name|}}
  {{test.helper name}}
{{/each}}

With context:

{
  "names": ["John", "Jeff"]
}

For:

Template template = handlebars.compileInline("{{#each names as |name|}}{{test.helper name}}{{/each}}");
System.out.println(template.apply(context));

The result would be Hello JohnHello Jeff on 4.5.1, but is empty on 4.5.2.

The root cause seems to be the change made to solve issue 820, namely the changed conditional in Variable#value (link). Effectively the new conditional now enforces that helpers may not contain a ., a behaviour which was allowed before the change and breaks existing templates relying on the old behaviour.

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