Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ZikFat opened this issue Jul 18, 2018 · 0 comments
Closed

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

ZikFat opened this issue Jul 18, 2018 · 0 comments
Milestone

Comments

@ZikFat
Copy link

ZikFat commented Jul 18, 2018

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.

@jknack jknack added this to the 4.1.1 milestone Oct 27, 2018
@jknack jknack closed this as completed in 8c9a3c3 Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants