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

Project information

Releases