Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module adds useful custom features to Twig templates. It offers functions for shuffling arrays, converting dates into "time ago" formats, and localizing numbers, currencies, and dates. Additionally, it provides tools for truncating text and wrapping words.

This module provides common additional features for Twig that do not directly belong in core. It used to include these through the twig/extensions package, but since that has been abandoned the extensions have been included in the module itself.

Filters

Extension name Description shuffle Shuffles an array. time_diff Converts dates to a time ago string like Facebook and Twitter has. localizeddate Formats dates using \IntlDateFormatter. localizednumber Formats numbers using \IntlDateFormatter. localizedcurrency Formats currencies using \IntlDateFormatter. truncate Truncates text to a certain length, optionally preserving words. wordwrap Wraps a string into new lines when it reaches a specific length.

Similar projects

  • Twig IntlExtension: provides alternatives to the localized* filters. Uses the twigphp/intl-extra package, but breaks the core format_date filter
  • Time diff: provides a time_diff filter, but isn't as flexible as the original Twig filter

Activity

Total releases
3
First release
Mar 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 3
Maintenance
Dormant

Release Timeline

Releases

Version Type Release date
8.x-2.5 Stable Jun 11, 2025
8.x-2.4 Stable May 19, 2025
8.x-2.3 Stable Mar 4, 2025