Next Level Twig: Extensions

Опубликовано: 02 Июнь 2026
на канале: Twin Cities Drupal
1,730
9

By Will Long

Drupal 8 features many enhancements, one of the most-prominent being the implementation of the Twig templating system. But are you really getting the most out of your Twig? If you’re not using Twig extensions, then no--you’re not.

Twig extensions allow developers to add processing capabilities to Twig’s template rendering via via custom filters and functions. The Twig Tweak module is a popular solution for adding common functionality to Twig, and as developers we can provide even more power to the folks working with our templates.

This session will cover:

Functionality provided by the core and contrib extensions
Implementing custom Twig extensions
Practical examples of functionality possibly through Twig extensions

Slides: https://www.dropbox.com/s/l8up8ob3f7p....

Sample code: https://github.com/kerasai/twig_ext_demo

Additional Resources:

Twig extension 1.x documentation: https://twig.symfony.com/doc/1.x/adva...
Drupal Core Twig Filters: https://www.drupal.org/node/2357633
Drupal Core Twig Functions: https://www.drupal.org/node/2486991
Twig Tweak: https://www.drupal.org/project/twig_t...
Twig Extensions: https://www.drupal.org/project/twig_e...

Learning Objectives & Outcomes:
Define Twig extensions, specifically the usage of functions and filters
Identify functionality of core Twig extension, and its shortcomings
Cover existing contrib options for Twig extensions
Roll a custom Twig extension

https://2018.tcdrupal.org/session/nex...