UNPKG

769 BPlain TextView Raw
1import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface';
2
3export class FilterAngular2ModulesHelper implements IHtmlEngineHelper {
4 public helperFunc(context: any, text: string, options: IHandlebarsOptions) {
5 const NG2_MODULES: string[] = [
6 'BrowserModule',
7 'FormsModule',
8 'HttpModule',
9 'RouterModule'
10 ];
11 let len = NG2_MODULES.length;
12 let i = 0;
13 let result = false;
14 for (i; i < len; i++) {
15 if (text.indexOf(NG2_MODULES[i]) > -1) {
16 result = true;
17 }
18 }
19 if (result) {
20 return options.fn(context);
21 } else {
22 return options.inverse(context);
23 }
24 }
25}