Skip to content

Commit 8d44f31

Browse files
committed
bug #1330 Fix twig deprecation: twig_escape_filter (WebMamba)
This PR was merged into the 2.x branch. Discussion ---------- Fix twig deprecation: twig_escape_filter | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | | License | MIT Commits ------- 647fa8c3 Fix twig deprecation: twig_escape_filter
2 parents 1d35ed7 + dac118b commit 8d44f31

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Util/LiveAttributesCollection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\LiveComponent\Util;
1313

1414
use 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
}

0 commit comments

Comments
 (0)