File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1
1
// using: regex, capture groups, and capture group variables.
2
- var templateUrlRegex = / t e m p l a t e U r l : ( .* ) $ / gm;
3
- var stylesRegex = / s t y l e U r l s : ( \s * \[ [ ^ \] ] * ?\] ) / g;
2
+ var templateUrlRegex = / t e m p l a t e U r l * : ( .* ) $ / gm;
3
+ var stylesRegex = / s t y l e U r l s * : ( \s * \[ [ ^ \] ] * ?\] ) / g;
4
4
var stringRegex = / ( [ ' " ] ) ( (?: [ ^ \\ ] \\ \1| .) * ?) \1/ g;
5
5
6
6
function replaceStringsWithRequires ( string ) {
Original file line number Diff line number Diff line change
1
+ var componentWithSpacing = `
2
+ import {Component} from '@angular/core';
3
+
4
+ @Component({
5
+ selector : 'test-component',
6
+ templateUrl : './some/path/to/file.html',
7
+ styleUrls : ['./app/css/styles.css']
8
+ })
9
+ export class TestComponent {}
10
+ ` ;
11
+
12
+ module . exports = componentWithSpacing ;
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ var sampleAngular2ComponentSimpleFixture = require('./sample_angular2_component_
2
2
var componentWithQuoteInUrls = require ( './component_with_quote_in_urls.js' ) ;
3
3
var componentWithMultipleStyles = require ( './component_with_multiple_styles.js' ) ;
4
4
var componentWithoutRelPeriodSlash = require ( './component_without_relative_period_slash.js' ) ;
5
+ var componentWithSpacing = require ( './component_with_spacing.js' ) ;
5
6
6
7
exports . simpleAngular2TestComponentFileStringSimple = sampleAngular2ComponentSimpleFixture ;
7
8
exports . componentWithQuoteInUrls = componentWithQuoteInUrls ;
8
9
exports . componentWithMultipleStyles = componentWithMultipleStyles ;
9
10
exports . componentWithoutRelPeriodSlash = componentWithoutRelPeriodSlash ;
11
+ exports . componentWithSpacing = componentWithSpacing ;
10
12
Original file line number Diff line number Diff line change @@ -95,5 +95,23 @@ describe("loader", function() {
95
95
) ;
96
96
} ) ;
97
97
98
+ it ( "Should convert html and style file strings to require()s regardless of spacing" , function ( ) {
99
+
100
+ loader . call ( { } , fixtures . componentWithSpacing )
101
+ . should
102
+ . be
103
+ . eql ( `
104
+ import {Component} from '@angular/core';
105
+
106
+ @Component({
107
+ selector : 'test-component',
108
+ template: require('./some/path/to/file.html'),
109
+ styles: [require('./app/css/styles.css')]
110
+ })
111
+ export class TestComponent {}
112
+ `
113
+ )
114
+
115
+ } ) ;
98
116
99
117
} ) ;
You can’t perform that action at this time.
0 commit comments