UNPKG

653 BPlain TextView Raw
1import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface';
2
3export class OrLengthHelper implements IHtmlEngineHelper {
4 public helperFunc(context: any /* any, any, ..., options */) {
5 let len = arguments.length - 1;
6 let options: IHandlebarsOptions = arguments[len];
7
8 // We start at 1 because of options
9 for (let i = 1; i < len; i++) {
10 if (typeof arguments[i] !== 'undefined') {
11 if (Object.keys(arguments[i]).length > 0) {
12 return options.fn(context);
13 }
14 }
15 }
16
17 return options.inverse(context);
18 }
19}