@@ -184,18 +184,18 @@ private function consumeAttributes(string $componentName): string
184
184
$ this ->expectAndConsumeChar ('} ' );
185
185
$ this ->expectAndConsumeChar ('} ' );
186
186
$ this ->consumeUntil ($ quote );
187
- $ isAttributeDynamic = true ;
188
- } else {
189
- $ attributeValue = $ this ->consumeUntil ($ quote );
190
- }
191
- $ this ->expectAndConsumeChar ($ quote );
192
187
193
- if ($ isAttributeDynamic ) {
194
188
$ attributes [] = sprintf ('%s: %s ' , $ key , $ attributeValue );
195
189
} else {
196
- $ attributes [] = sprintf ("%s: '%s' " , $ key , str_replace ("' " , "\' " , $ attributeValue ));
197
- }
190
+ $ attributeValue = $ this ->consumeAttributeValue ($ quote );
198
191
192
+ if ($ isAttributeDynamic ) {
193
+ $ attributes [] = sprintf ('%s: %s ' , $ key , $ attributeValue );
194
+ } else {
195
+ $ attributes [] = sprintf ("%s: '%s' " , $ key , $ attributeValue );
196
+ }
197
+ }
198
+ $ this ->expectAndConsumeChar ($ quote );
199
199
$ this ->consumeWhitespace ();
200
200
}
201
201
@@ -352,6 +352,43 @@ private function consumeUntilEndBlock(): string
352
352
return substr ($ this ->input , $ start , $ this ->position - $ start );
353
353
}
354
354
355
+ private function consumeAttributeValue (string $ quote ): string
356
+ {
357
+ $ attributeValue = '' ;
358
+ while ($ this ->position < $ this ->length ) {
359
+ if (substr ($ this ->input , $ this ->position , 1 ) === $ quote ) {
360
+ break ;
361
+ }
362
+
363
+ if ("\n" === $ this ->input [$ this ->position ]) {
364
+ ++$ this ->line ;
365
+ }
366
+
367
+ if ('\'' === $ this ->input [$ this ->position ]) {
368
+ $ attributeValue .= "\' " ;
369
+ ++$ this ->position ;
370
+
371
+ continue ;
372
+ }
373
+
374
+ if ('{{ ' === substr ($ this ->input , $ this ->position , 2 )) {
375
+ $ this ->consume ('{{ ' );
376
+ $ attributeValue .= "'~( " ;
377
+ $ this ->consumeWhitespace ();
378
+ $ value = rtrim ($ this ->consumeUntil ('}} ' ));
379
+ $ this ->expectAndConsumeChar ('} ' );
380
+ $ this ->expectAndConsumeChar ('} ' );
381
+ $ attributeValue .= $ value ;
382
+ $ attributeValue .= ")~' " ;
383
+ }
384
+
385
+ $ attributeValue .= $ this ->input [$ this ->position ];
386
+ ++$ this ->position ;
387
+ }
388
+
389
+ return $ attributeValue ;
390
+ }
391
+
355
392
private function doesStringEventuallyExist (string $ needle ): bool
356
393
{
357
394
$ remainingString = substr ($ this ->input , $ this ->position );
0 commit comments