Files
ngx-translate-extract/src/parsers/abstract-template.parser.ts
Kim Biesbjerg 102286a209 - (feat) add concept of post processors
- (feat) add 'key as default value' post processor (closes #109)
- (chore) move clean functionality to a post processor
- (chore) move sort functionality to a post processor
- (refactor) get rid of leading underscore on protected properties/methods
2019-06-11 23:06:47 +02:00

25 lines
553 B
TypeScript

export abstract class AbstractTemplateParser {
/**
* Checks if file is of type javascript or typescript and
* makes the assumption that it is an Angular Component
*/
protected isAngularComponent(path: string): boolean {
return (/\.ts|js$/i).test(path);
}
/**
* Extracts inline template from components
*/
protected extractInlineTemplate(contents: string): string {
const regExp: RegExp = /template\s*:\s*(["'`])([^\1]*?)\1/;
const match = regExp.exec(contents);
if (match !== null) {
return match[2];
}
return '';
}
}