Skip to content

Commit 11dcebf

Browse files
committed
minor #13715 [String] Allow to define additional slugger substitutions (javiereguiluz)
This PR was merged into the 5.1 branch. Discussion ---------- [String] Allow to define additional slugger substitutions Fixes #13584. Commits ------- aaabeb8 [String] Allow to define additional slugger substitutions
2 parents eda712e + aaabeb8 commit 11dcebf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/string.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ that only includes safe ASCII characters::
468468
$slug = $slugger->slug('Wôrķšƥáçè ~~sèťtïñğš~~');
469469
// $slug = 'Workspace-settings'
470470

471+
// you can also pass an array with additional character substitutions
472+
$slugger = new AsciiSlugger('en', ['%' => 'percent', '€' => 'euro']);
473+
$slug = $slugger->slug('10% or 5€');
474+
// $slug = '10-percent-or-5-euro'
475+
476+
.. versionadded:: 5.1
477+
478+
The feature to define additional substitutions was introduced in Symfony 5.1.
479+
471480
The separator between words is a dash (``-``) by default, but you can define
472481
another separator as the second argument::
473482

0 commit comments

Comments
 (0)