Add tests and allow more liberal spacing with get/instant calls
This commit is contained in:
@@ -12,7 +12,7 @@ export abstract class AbstractTemplateParser {
|
||||
* Extracts inline template from components
|
||||
*/
|
||||
protected _extractInlineTemplate(contents: string): string {
|
||||
const match = new RegExp(/template\s*:\s*(["'`])((.|[\r\n])+?[^\\])\1/).exec(contents);
|
||||
const match = new RegExp(/template\s*:\s*(["'`])([^\1]*?)\1/).exec(contents);
|
||||
if (match !== null) {
|
||||
return match[2];
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac
|
||||
protected _parseTemplate(template: string): TranslationCollection {
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
|
||||
const regExp = new RegExp(/(['"`])([^\1\r\n]*)\1\s*\|\s*translate(:.*?)?/, 'g');
|
||||
const regExp = new RegExp(/(['"`])([^\1]*)\1\s*\|\s*translate/, 'g');
|
||||
|
||||
let matches: RegExpExecArray;
|
||||
while (matches = regExp.exec(template)) {
|
||||
|
@@ -11,10 +11,10 @@ export class ServiceParser implements ParserInterface {
|
||||
return collection;
|
||||
}
|
||||
|
||||
const methodRegExp: RegExp = new RegExp(/(?:get|instant)\s*\(\s*(\[?(['"`])([^\1\r\n]+)\2\]?)/);
|
||||
const methodRegExp: RegExp = new RegExp(/(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*)\2\s*\]?)/);
|
||||
const regExp: RegExp = new RegExp(`${translateServiceVar}\.${methodRegExp.source}`, 'g');
|
||||
|
||||
let matches;
|
||||
let matches: RegExpExecArray;
|
||||
while (matches = regExp.exec(contents)) {
|
||||
if (this._stringContainsArray(matches[1])) {
|
||||
collection = collection.addKeys(this._stringToArray(matches[1]));
|
||||
|
Reference in New Issue
Block a user