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

Ambiguity in a Helper function's first parameter #1075

Open
dpeterson-git opened this issue Sep 11, 2023 · 0 comments
Open

Ambiguity in a Helper function's first parameter #1075

dpeterson-git opened this issue Sep 11, 2023 · 0 comments

Comments

@dpeterson-git
Copy link

In the current Handlebars.java behavior, the first parameter to a Helper function is either the current context object OR the parameter supplied in the template. From a Helper's perspective, it is not possible to disambiguate these two cases. Thus, it is not possible to do proper parameter validation on the helper's arguments.

The following two calls look identical from a Helper function's perspective:

{{foo}}
{{foo this}}

This behavior of automatically injecting the context object in the first parameter's position when no arguments are supplied also causes Handlebars.java to behave differently than Handlebars JS. Consider the following template:

{{#if}}Yes{{else}}No{{/if}}

In Handlebars.java, this evaluates to Yes.
In Handlebars JS, this produces a runtime error - #if requires exactly one argument.

Please consider providing a mechanism for a Helper function to obtain its actual argument values for all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant