File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Component/AssetMapper/ImportMap Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ public function __construct(private readonly ImportMapRenderer $importMapRendere
22
22
{
23
23
}
24
24
25
- public function importmap (?string $ entryPoint = 'app ' ): string
25
+ public function importmap (?string $ entryPoint = 'app ' , array $ attributes = [] ): string
26
26
{
27
- return $ this ->importMapRenderer ->render ($ entryPoint );
27
+ return $ this ->importMapRenderer ->render ($ entryPoint, $ attributes );
28
28
}
29
29
}
Original file line number Diff line number Diff line change @@ -29,15 +29,16 @@ public function __construct(
29
29
) {
30
30
}
31
31
32
- public function render (string $ entryPoint = null ): string
32
+ public function render (string $ entryPoint = null , array $ attributes = [] ): string
33
33
{
34
34
$ attributeString = '' ;
35
35
36
- if (isset ($ this ->scriptAttributes ['src ' ]) || isset ($ this ->scriptAttributes ['type ' ])) {
36
+ $ attributes += $ this ->scriptAttributes ;
37
+ if (isset ($ attributes ['src ' ]) || isset ($ attributes ['type ' ])) {
37
38
throw new \InvalidArgumentException (sprintf ('The "src" and "type" attributes are not allowed on the <script> tag rendered by "%s". ' , self ::class));
38
39
}
39
40
40
- foreach ($ this -> scriptAttributes as $ name => $ value ) {
41
+ foreach ($ attributes as $ name => $ value ) {
41
42
$ attributeString .= ' ' ;
42
43
if (true === $ value ) {
43
44
$ attributeString .= $ name ;
@@ -70,7 +71,7 @@ public function render(string $entryPoint = null): string
70
71
}
71
72
72
73
if (null !== $ entryPoint ) {
73
- $ output .= "\n<script type= \"module \">import ' " .str_replace ("' " , "\\' " , $ entryPoint )."';</script> " ;
74
+ $ output .= "\n<script type= \"module \"$ attributeString >import ' " .str_replace ("' " , "\\' " , $ entryPoint )."';</script> " ;
74
75
}
75
76
76
77
return $ output ;
You can’t perform that action at this time.
0 commit comments