Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The attributes are wildly used throughout the theme functions and I think they should be available and converted to Attribute() class automatically directly in the theme engine so the developer won' need to define and transfomr them each time a new theme functions is created.
As a developer I would really like this feature.
Comments
Comment #1
star-szrHi @ivanjaros, core already does both of these things for you.
_template_preprocess_default_variables() sets up the 'attributes' variable, as well as title_attributes and content_attributes.
The code below from \Drupal\Core\Theme\ThemeManager::theme() initializes the variables as Attribute objects. More specifically, during preprocess the variables are just arrays of attributes similar to D7, and these arrays are converted to Attribute objects before being passed to the template:
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedGreat!