File tree 2 files changed +19
-7
lines changed
2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -169,13 +169,22 @@ export class ElementOfHtml {
169
169
// Removing spaces necessary for readability of a comment
170
170
commentWithText = commentWithText . slice ( 1 , - 1 )
171
171
172
- let textBefore = commentWithText . match ( / ^ .* (? = { { ) / s) ?. at ( 0 )
173
- let text = commentWithText . match ( / (?< = { { ) .* ?(? = } } | $ ) / s) ?. at ( 0 )
174
- let textAfter = commentWithText . match ( / (?< = } } ) .* $ / s) ?. at ( 0 )
172
+ let text = [
173
+ // Get everything up to {{
174
+ commentWithText . match ( / ^ .* (? = { { ) / s) ?. at ( 0 ) ,
175
+ // Get everything in {{ }}
176
+ commentWithText . match ( / (?< = { { ) .* ?(? = } } | $ ) / s) ?. at ( 0 ) ,
177
+ // Get everything after }}
178
+ commentWithText . match ( / (?< = } } ) .* $ / s) ?. at ( 0 )
179
+ ]
180
+
181
+ for ( let i = 0 ; i < text . length ; i ++ ) {
182
+ if ( ! text [ i ] ?. trim ( ) ) {
183
+ text [ i ] = ''
184
+ }
185
+ }
175
186
176
- this . textBefore = textBefore
177
- this . text = text
178
- this . textAfter = textAfter
187
+ [ this . textBefore , this . text , this . textAfter ] = text
179
188
}
180
189
#setParentAndSelfSelector( fullSelector ) {
181
190
let partsOfSelector = fullSelector . split ( ' ' )
Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ test('New lines are placed correctly', () => {
6
6
assert . equal (
7
7
new CssToHtml ( {
8
8
css : `
9
- div { /* {{ text inside }} */ }
9
+ div { /*
10
+ {{ text inside }}
11
+
12
+ */ }
10
13
div i { /* {{ text of i }} after */ }
11
14
` ,
12
15
} )
You can’t perform that action at this time.
0 commit comments