When creating templates you often run into an issue where you need to create a unique identifier. The solution is often to create a class from a string in the template. Drupal has a great function to do this, the drupal_html_class function.

Proposed resolution

Create a Twig extension that hooks into the drupal_html_class function. In the Twig training at NYCCamp, where this was first brought up, we proposed calling it 'classify' extension.

Remaining tasks

Create a patch.

User interface changes


API changes



Dave Reid’s picture

Status: Active » Closed (duplicate)
Related issues: +#2283301: Add Twig filters for drupal_html_class() and drupal_clean_id_identifier()

Implemented with #2283301: Add Twig filters for drupal_html_class() and drupal_clean_id_identifier(). Sorry I wasn't able to search for issues earlier.