File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \UX \LiveComponent \Util ;
1313
1414use Twig \Environment ;
15+ use Twig \Extension \EscaperExtension ;
1516
1617/**
1718 * An array of attributes that can eventually be returned as an escaped array.
@@ -99,6 +100,11 @@ public function setBrowserEventsToDispatch(array $browserEventsToDispatch): void
99100
100101 private function escapeAttribute (string $ value ): string
101102 {
102- return twig_escape_filter ($ this ->twig , $ value , 'html_attr ' );
103+ if (method_exists (EscaperExtension::class, 'escape ' )) {
104+ return EscaperExtension::escape ($ this ->twig , $ value , 'html_attr ' );
105+ }
106+
107+ // since twig/twig 3.9.0: Using the internal "twig_escape_filter" function is deprecated.
108+ return (string ) twig_escape_filter ($ this ->twig , $ value , 'html_attr ' );
103109 }
104110}
Original file line number Diff line number Diff line change 1414namespace Symfony \UX \StimulusBundle \Dto ;
1515
1616use Twig \Environment ;
17+ use Twig \Extension \EscaperExtension ;
1718
1819/**
1920 * Helper to build Stimulus-related HTML attributes.
@@ -214,6 +215,11 @@ private function getFormattedValue(mixed $value): string
214215
215216 private function escapeAsHtmlAttr (mixed $ value ): string
216217 {
218+ if (method_exists (EscaperExtension::class, 'escape ' )) {
219+ return EscaperExtension::escape ($ this ->env , $ value , 'html_attr ' );
220+ }
221+
222+ // since twig/twig 3.9.0: Using the internal "twig_escape_filter" function is deprecated.
217223 return (string ) twig_escape_filter ($ this ->env , $ value , 'html_attr ' );
218224 }
219225
You can’t perform that action at this time.
0 commit comments