Closed michaelrog closed 1 year ago
Takes an array of strings (or stringy things) and concatenates them into a delimited list, with optional "Oxford comma" treatment and customizable final conjunction.
['Thing One', 'Thing Two', 'Thing Three'] | commaList >> "Thing One, Thing Two, and Thing Three"
['Thing One', 'Thing Two', 'Thing Three'] | commaList($oxford = false, $and = 'und ') >> "Thing One, Thing Two und Thing Three"
['Thing One', 'Thing Two', 'Thing Three'] | commaList($glue = ' + ', $and = 'finally, ') >> "Thing One + Thing Two + finally, Thing Three"
Twig added this functionality to the join filter in 2.6.1. 👍🏼
join
Takes an array of strings (or stringy things) and concatenates them into a delimited list, with optional "Oxford comma" treatment and customizable final conjunction.