Skip to content

"empty" variable name does not work in a partial #643

@ZikFat

Description

@ZikFat

If you use the key "empty" in your model it won't resolve correctly when referenced from a partial template. For example:

template.hbs

template: {{empty}}
{{> partial}}

partial.hbs

partial: {{empty}}

Code:

Map<String, Object> model = new HashMap<>();
model.put("empty", false);
Template template = handlebars.compile("template");
System.out.println(template.apply(model));

Output:

template: false
partial: true

It looks like this is happening because the partial's extended context gets set to an empty map and is also treated as higher priority for resolution than the original context. When the partial tries to resolve "empty" against the extended context it produces a value of true because the JavaBeanValueResolver calls the Map.isEmpty() method.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions