Add modules and themes as twig namespaces

Created on 25 November 2013, over 11 years ago
Updated 16 June 2025, 11 days ago

Updated: Comment #N

Problem/Motivation

Twig has this concept of template include and extends. Currently we have to specify the complete path to a template file to include it. This fact, makes this feature of twig unusable for contrib module and themes.

Twig docs for namespaces

Proposed resolution

Add a twig namespace for each module and theme (somewhere in CoreServiceProvider::registerTwig).

Syntax in templates without namespaces.

  {% extends "core/themes/bartik/templates/node.html.twig" %}

Syntax in templates namespaces.

  {% extends "@bartik/node.html.twig" %}

Remaining tasks

Implementations, Tests, Docs

User interface changes

None.

API changes

None. We do not use include or extends in our templates atm.

πŸ“Œ Task
Status

Fixed

Version

8.0 ⚰️

Component

theme system

Created by

πŸ‡©πŸ‡ͺGermany webflo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024