Creating Another Twig Function

We create another Twig function but this time we pass in an array of words to use as replacements.

In this exam­ple, we’re going to manip­u­late text passed into the func­tion using val­ues passed into the func­tion and then output.

Here’s how we’ll use it in our Twig template:

{{ plantify(['soy', 'beans', 'tofu', 'seitan', 'mushrooms', 'Beyond Burger', 'Tofurkey'], text) }}

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