Implements the cocur/slugify class as a Twig filter for Drupal.

This work carries forward the work in the sandbox here, made compatible for Drupal 9 and 10+.

Usage

After enabling the module you can use the filter in a Twig template on any text field or string value.

Example, on a node with a field_foo value of "This is an Example"

{{ node.field_foo.value|slugify }}

Would render "this-is-an-example".

The filter supports most of the options that the cocur/slugify library supports. For example, disabling the forcing of lowercase and changing the seperator to ***, pass an options object:

{{ node.field_foo.value|slugify({'lowercase': false, "separator": "***"}) }}

Would render "This***is***an***Example".

Supporting organizations: 
Supporting Development

Project information

Releases