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

Comments

timohuisman created an issue. See original summary.

quietone’s picture

Version: 11.0.x-dev » 11.x-dev

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.