Add Twig Types to core templates

Created on 25 October 2024, 4 months ago

Problem/Motivation

In Twig 3.13 there is a new tag types introduced. It gives us the ability to declare the types of the template variables. See https://twig.symfony.com/doc/3.x/tags/types.html and https://github.com/twigphp/Twig/issues/4165

Proposed resolution

Add Twig types to all core templates based on the types in the template preprocess functions. For example block.html.twig could contain;

{#
/**
* ...
*
* @see template_preprocess_block()
*/
#}
{% types {
plugin_id: 'string',
label: 'string',
configuration: 'array',
in_preview: 'boolean',
content: 'array'
attributes: '\Drupal\Core\Template\Attribute',
...
} %}

...

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component

theme system

Created by

🇳🇱Netherlands timohuisman Leiden, Netherlands

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

Comments & Activities

Production build 0.71.5 2024