2026 Community Survey results are here! See how the Craft CMS community works. results are live!

Create a free account to get access to additional free training videos. Enjoy this free video from CraftQuest! Create a free account to get access to additional free training videos. Join the Community

The Twig Filter and Functions We'll Build

A brief review of what we'll create in this course.

In this course we’re going to build a Twig fil­ter and a Twig func­tion that will make it easy to plan­ti­fy” any text we pass in. Our task here is to sat­is­fy a fea­ture request to have the option to remove all instances of meat from some text. 

(This is, of course, a lit­tle joke. It is in response to our friend Andrew Welch and the time he demon­strat­ed the help­ful­ness of Type­script with an exam­ple that refused non-meat addi­tions to an array of items on a vir­tu­al char­cu­terie board.

Let’s say the vari­able text con­tains a para­graph of text with many instances of meat in it. We want to remove all men­tions of meat and replace it with men­tions of plants. 

Okay, let’s get to building.

Transcript

Premium

Follow along with the full transcript

Search every word, click any line to jump to that moment, and read along as you watch — a CraftQuest Premium feature.

Sign up for Premium
Instructor
Level
Intermediate
Date Published
June 14, 2021