Margaret Thatcher, Ronald McDonald, David Bowie, Zendaya, Vanessa down the street. What do these people (does Ronnie count as a person?) have in common? Hell if I know.
I wrote a Statamic 3 addon that I’ve been copying and pasting into every Statamic project I work on. It’s basically Laravel’s Arr::get() helper in Antlers. I used something similar in v2 back when Jim-Jam and I cranked out Statamic builds left and right and I more actively battled my nemesis.
It helps me:
- Streamline my markup
- Easily add new variants (especially easy for minor differences like colors, sizes, padding… all that jazz 🎷) (doubly-especially wonderful with Tailwind)
- Allow content authors to oh-so-simply choose which variant to render
- And probably some other stuff not coming to mind right now 🤔
Anyway, check it out on GitHub, Packagist, and the Statamic Marketplace. Let me know if you come up with more interesting use cases or if you run into any problems!
Addon in the Statamic Marketplace. Oh, yes. One other neat thing I didn’t document because it’s more of a side effect than an intentional feature: Array Get allows you to throw Antlers code in your front-matter and have it parsed in the output. I did that all the time in v2 (and probably v1?), but (last time I checked) v3 doesn’t support Antlers in your front-matter.