TopShelfCraft / Wordsmith

A plugin for Craft CMS to help you manage and manipulate text.
Other
30 stars 20 forks source link

[FR] Comma list function #23

Closed michaelrog closed 1 year ago

michaelrog commented 5 years 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"
michaelrog commented 1 year ago

Twig added this functionality to the join filter in 2.6.1. 👍🏼