File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,7 @@ public function __construct(private readonly HookRendererInterface $innerRendere
2424 public function render (array $ hookNames , array $ hookContext = []): string
2525 {
2626 $ renderedParts = [];
27- $ renderedParts [] = $ this ->getOpeningDebugComment ($ hookNames );
2827 $ renderedParts [] = trim ($ this ->innerRenderer ->render ($ hookNames , $ hookContext ));
29- $ renderedParts [] = $ this ->getClosingDebugComment ($ hookNames );
3028
3129 return implode (\PHP_EOL , $ renderedParts );
3230 }
Original file line number Diff line number Diff line change @@ -27,10 +27,7 @@ public function __construct(private readonly HookableRendererInterface $innerRen
2727
2828 public function render (AbstractHookable $ hookable , HookableMetadata $ metadata ): string
2929 {
30- $ renderedParts = [];
31- $ renderedParts [] = $ this ->getOpeningDebugComment ($ hookable );
32- $ renderedParts [] = trim ($ this ->innerRenderer ->render ($ hookable , $ metadata ));
33- $ renderedParts [] = $ this ->getClosingDebugComment ($ hookable );
30+ $ renderedParts [] = $ this ->wrapWithDebugAttributes (trim ($ this ->innerRenderer ->render ($ hookable , $ metadata )), $ hookable );
3431
3532 return implode (\PHP_EOL , $ renderedParts );
3633 }
@@ -70,4 +67,16 @@ private function getClosingDebugComment(AbstractHookable $hookable): string
7067 $ hookable ->priority (),
7168 );
7269 }
70+
71+ private function wrapWithDebugAttributes (string $ content , AbstractHookable $ hookable ): string
72+ {
73+ dump ($ hookable );
74+ $ debugAttributes = sprintf ('data-hook="%s" data-hookable="%s" data-hookable-config="%s" ' ,
75+ htmlspecialchars ($ hookable ->hookName , ENT_QUOTES ),
76+ htmlspecialchars ($ hookable ->name , ENT_QUOTES ),
77+ $ hookable ->priority ()
78+ );
79+
80+ return preg_replace ('/<(?!\/)(\w+)([^>]*)>/ ' , '<$1$2 ' . $ debugAttributes . '> ' , $ content , 1 );
81+ }
7382}
You can’t perform that action at this time.
0 commit comments