Skip to content

Commit

Permalink
fix: support backtick quoted templateUrl (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
SEIAROTg authored and ahnpnl committed Aug 8, 2018
1 parent 6991752 commit 145c8ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions __tests__/preprocessor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,19 @@ const sources = [
'../media-box.component.scss',
'./media-box-h0.component.scss'
],
})`
})`,
// double quote
`@Component({
selector: 'xc-media-box-h0',
templateUrl: "./media-box-h0.component.html",
styleUrls: [ '../media-box.component.scss' ],
})`,
// backtick
`@Component({
selector: 'xc-media-box-h0',
templateUrl: \`./media-box-h0.component.html\`,
styleUrls: [ '../media-box.component.scss' ],
})`,
];

const config = {
Expand All @@ -72,7 +84,7 @@ sources.forEach(source => {
const result = process(source, '', config);
expect(result).toMatch('styles: []');
expect(result).toMatch(
"template: require('./media-box-h0.component.html')"
/template: require\(['"`]\.\/media-box-h0\.component\.html['"`]\)/
);
});
});
2 changes: 1 addition & 1 deletion preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const process = require('ts-jest').process;
const TEMPLATE_URL_REGEX = /templateUrl\s*:\s*('|")(\.\/){0,}(.*)('|")/g;
const TEMPLATE_URL_REGEX = /templateUrl\s*:\s*('|"|`)(\.\/){0,}(.*)('|"|`)/g;
const STYLE_URLS_REGEX = /styleUrls\s*:\s*\[[^\]]*\]/g;
const ESCAPE_TEMPLATE_REGEX = /(\${|\`)/g;

Expand Down

0 comments on commit 145c8ea

Please sign in to comment.