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

In java, equals helper returns java.lang.IllegalArgumentException: "could not find helper: 'eq'" #1063

Open
keanerickson-mc opened this issue Apr 10, 2023 · 1 comment

Comments

@keanerickson-mc
Copy link

keanerickson-mc commented Apr 10, 2023

For two variables, boolean "skip" and string "name", I'm trying to make this not print anything if "skip" is true

{{# eq skip "false"}} {{name}} {{/eq}}
Results in
"could not find helper: 'eq'"

I get the same behavior if I use "equals" or "equal" instead of "eq" for the helper

It seems that using "{{#if skip}}{{else}}" is sufficient, but I'd like to understand the eq helper

@HarrishSreedhar
Copy link

HarrishSreedhar commented Aug 11, 2023

For two variables, boolean "skip" and string "name", I'm trying to make this not print anything if "skip" is true

{{# eq skip "false"}} {{name}} {{/eq}} Results in "could not find helper: 'eq'"

I get the same behavior if I use "equals" or "equal" instead of "eq" for the helper

It seems that using "{{#if skip}}{{else}}" is sufficient, but I'd like to understand the eq helper

@keanerickson-mc - I had faced the very similar issue, but the below solution worked and template loaded as expected.

Error trace -

IllegalArgumentException: could not find helper: 'eq'] with root cause
java.lang.IllegalArgumentException: could not find helper: 'eq'

You can try with a custom code. Register the necessary class (ConditionalHelpers.eq) in your case.

private final Handlebars handlebars;

handlebars.registerHelper("eq", ConditionalHelpers.eq);

Now consume the above handlerbars in your service -

Template handlerBarTemplate = handlebars.compileInline(template);

  handlerBarTemplate.apply(context, writer);

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

2 participants