Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

This course is the most refreshing take on teaching design that I've come across.

— Mikaël Sévigny, Developer

sentence_list Modifier

Turn a simple array into a friendly comma delimited list with the word "and" before the last item.

things:
- batman
- zombies
- scrunchies
I like {{ things | sentence_list }}.
I like {{ Statamic::modify($things)->sentenceList() }}.
I like batman, zombies, and scrunchies.

By default, the "glue" is the word "and", and will be translated appropriately. But, you can change it with the first argument:

I like {{ things | sentence_list('&') }}.
I like {{ Statamic::modify($things)->sentenceList('&') }}.
I like batman, zombies, & scrunchies.

The second argument controls the oxford comma. Set that to 0 and it'll get removed:

I like {{ things | sentence_list('and', 0) }}.
I like {{ Statamic::modify($things)->sentenceList(['and', 0]) }}.
I like batman, zombies and scrunchies.
HR: Section
Related Modifiers

These similar modifiers may aid you on your quest.

rotate-vertical
HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →