How can I add an OR condition in handlebar using java? I want to do something like:
{{#if condition1}} || {{#if condition2}}
do something
.....
......
{{else}}
do something else...
{{/if}}
Do I need to register some helper? For example for comparing if one number is greater than other, I have written a helper like:
handlebars.registerHelper("ifgt", new Helper<Integer>() {
@Override
public CharSequence apply(Integer value, Options options) throws IOException {
if (value == null || options.param(0) == null) return options.inverse();
if (value.compareTo(options.param(0)) > 0) {
return options.fn();
}
return options.inverse();
}
});
Finally found a library for basic operations like or,and,not,mathematical operations in handlebar java.
Refer: http://handlebars-java-helpers.beryx.org/releases/latest/#_or
For usage with java : https://github.com/beryx/handlebars-java-helpers/issues/1#issuecomment-355653085