1 | import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface';
|
2 |
|
3 | export class OneParameterHasHelper implements IHtmlEngineHelper {
|
4 | public helperFunc(context: any, tags, typeToCheck): string {
|
5 | let result = false;
|
6 | let len = arguments.length - 1;
|
7 | let options: IHandlebarsOptions = arguments[len];
|
8 |
|
9 | let i = 0,
|
10 | leng = tags.length;
|
11 |
|
12 | for (i; i < leng; i++) {
|
13 | if (typeof tags[i][typeToCheck] !== 'undefined' && tags[i][typeToCheck] !== '') {
|
14 | result = true;
|
15 | }
|
16 | }
|
17 |
|
18 | if (result) {
|
19 | return options.fn(context);
|
20 | } else {
|
21 | return options.inverse(context);
|
22 | }
|
23 | }
|
24 | }
|