Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Twig Extender

Security covered Under active development 432 sites

Part of the Twig ecosystem · 43 projects

This module provides a plugin system for Drupal to add custom Twig filters and functions. It allows developers to easily extend Twig's capabilities within their Drupal projects.

Add a simple plugin system to add new twig extensions (Filter and Functions). Provides a new service provider for "twig.extensions" to add new plugins.

Versions

Drupal 8.2 or lower: Use Twig Extender 8.1
Drupal 8.3 or higher: Use Twig Extender 8.2

Documentation

Basic filter and functions: https://github.com/erik-seifert/twig_extender
Extra filter and function: https://github.com/erik-seifert/twig_extender/tree/8.x-2.x/modules/twig_...

Add new functions and filters

Please add your suggestions here.
https://www.drupal.org/node/2701695

Simple Plugin

<?php

namespace Drupal\twig_extender\Plugin\TwigPlugin;

use Drupal\twig_extender\Plugin\Twig\TwigPluginBase;
use Drupal\Component\Utility\Unicode;

/**
 * Example plugin Hello World.
 *
 * @TwigPlugin(
 *   id = "twig_extender_hello",
 *   label = @Translation("Hello world plugin"),
 *   type = "function",
 *   name = "hello",
 *   function = "hello"
 * )
 */
class HelloWorld extends TwigPluginBase {

  /**
   * Implement hello world function.
   */
  public function hello() {
    return 'Hello World';
  }

}

Using in Template

{% hello() %}
Drupal 9–10 · not 11

Ask your assistant about Twig Extender

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Dec 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
5.x-dev Dev 9–10 Dec 7, 2023
5.0.x-dev Dev 9–10 Dec 7, 2023
4.1.0 Stable 8–10 Dec 7, 2023
5.1.0 Stable 9–10 Dec 7, 2023