Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

Twig Toolkit

7 sites Security covered Drupal 10–11

Part of the Twig ecosystem · 26 projects

View on drupal.org

Twig Toolkit for Drupal provides convenient Twig helpers for creating HTML classes, attributes, and inline styles within Drupal templates. It also includes an `html_element` tag that works seamlessly with Drupal's Attribute objects, making it useful for component-driven theming and design systems.

Twig Toolkit for Drupal integrates the studiometa/twig-toolkit library with Drupal’s Twig layer. It provides ergonomic helpers for composing HTML classes, attributes, and inline styles, plus a Drupal-compatible html_element tag that works with Drupal Attribute objects.

Features

  • Exposes Twig Toolkit’s Twig helpers in Drupal templates:
    • html_classes() for building class attributes from strings/arrays/objects.
    • html_styles() for building inline style attributes from key/value maps.
    • html_attributes() and merge_html_attributes() for rendering and
      merging attributes safely and consistently.
    • {% html_element %}...{% end_html_element %} for rendering elements with
      dynamic tags and complex attributes.
  • Drupal compatibility for attribute handling:
    • Automatically converts Drupal \Drupal\Core\Template\Attribute objects to
      arrays for use with Twig Toolkit.
  • Useful for component-driven theming, design systems, and templates that need clean, reusable
    attribute composition.

Post-Installation

After enabling the module, the functions/filters/tag are immediately available in Twig templates. There is no configuration form. Use it directly in your theme/module templates to build attributes and render elements. Clear caches after enabling (e.g. drush cr).

Additional Requirements

  • Requires the PHP library
    studiometa/twig-toolkit
    (typically installed via Composer).
  • No additional Drupal modules are required beyond Drupal core.
  • No specific recommendations. This module is most useful alongside component-based theming approaches and reusable Twig components.

Similar projects

  • Twig Tweak: offers many Drupal-specific Twig utilities, but is broader in
    scope. This module focuses on integrating the Twig Toolkit attribute/class/style helpers and
    html_element tag.
  • Drupal’s core Attribute API: provides attribute objects; this module
    complements it with ergonomic composition helpers and a convenient element-rendering tag.

Supporting this Module

If you’d like to support upstream development of the underlying library, consider following and supporting the authors of studiometa/twig-toolkit.

Community Documentation

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
Mar 2026
Latest release
5 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.3 Stable 10–11 Mar 20, 2026
1.0.2 Stable 10–11 Mar 20, 2026
1.0.1 Stable 10–11 Mar 20, 2026
1.0.x-dev Dev 10–11 Mar 10, 2026