[2.0.0-rc3] About Drupal template wrappers

Created on 26 January 2025, 27 days ago

We need a final discussion about those wrappers and a strong and bold policy about them.

BlockSource and block.html.twig

We are directly rendering BlockPluginInterface::build() instead of the "#theme" => "block" wrapper.

So, we are skipping block.html.twig template and rendering directly the content variable:

<div{{ attributes }}>
  {{ title_prefix }}
  {% if label %}
    <h2{{ title_attributes }}>{{ label }}</h2>
  {% endif %}
  {{ title_suffix }}
  {% block content %}
    {{ content }}
  {% endblock %}
</div>

This was a good decision IMHO because:

  • it is consistent with our long term vision of skipping the ThemeManager and getting rid of those kind of wrappers
  • we are not "afraid" of ignoring the modules which are altering with hook_preprocess_block because we also loading directly the plugin form and not triggering hook_block_form_block_form_alter.
    So a module like UI Styles (using both hook_preprocess_block and hook_block_form_block_form_alter) will not be compatible, but that's OK.

However:

  • why are we storing label and label_display properties which are related to the wrapper?
  • are we really sure we want to lose the features and ecosystem related to "#theme" => "block" wrapper? Let's have a last talk

Field Formatters (and field.html.twig)

We already talk about that: 📌 [2.0.0-beta5] Check hook_field_formatter_third_party_settings_form compatibility Active but I am not sure we did the epxected follow-up issue and we ended the discussion.

Do we currently trigger "#theme" => "field" ?

We need to adopt here the exact same policy than for blocks:

  • If we skip field.html.twig because we think it is an outdated annoying layer which must die, we may miss compatibility with some modules. (and we need to be sure we are not triggering hook_field_formatter_third_party_settings_form either.
  • Or, we support both hook_field_formatter_third_party_settings_form and hook_preprocess_field
📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France pdureau Paris

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

Comments & Activities

Production build 0.71.5 2024