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();
}
});
Handlerbars for Java (since v4 I think) comes with a support class
ConditionalHelpers
which provides conditional logic operators, although you still have to register these before they can be used.for example