(refactor) get rid of AbstractTemplateParser

This commit is contained in:
Kim Biesbjerg
2019-06-12 11:50:23 +02:00
parent 102286a209
commit 53eb4d1202
7 changed files with 38 additions and 61 deletions

View File

@@ -1,3 +1,22 @@
export function _(key: string | string[]): string | string[] {
return key;
}
/**
* Assumes file is an Angular component if type is javascript/typescript
*/
export function isPathAngularComponent(path: string): boolean {
return (/\.ts|js$/i).test(path);
}
/**
* Extract inline template from a component
*/
export function extractComponentInlineTemplate(contents: string): string {
const regExp: RegExp = /template\s*:\s*(["'`])([^\1]*?)\1/;
const match = regExp.exec(contents);
if (match !== null) {
return match[2];
}
return '';
}