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 Descriptionshuffle
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 coreformat_datefilter - Time diff: provides a
time_difffilter, but isn't as flexible as the original Twig filter