Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Summary:

Since render elements can accept multiple theme wrappers, we need a way to pass unique arguments to each one.

In Drupal 7 this was impossible since the '#wrapper_attributes' were passed blindly to all theme_wrappers, and to make matters worse, these attributes would only be used if the theme_wrapper specifically listened for those '#wrapper_attributes' and applied them.

In Drupal 8, we've allowed individual variables to be passed to each theme_wrapper by changing the structure of the theme_wrapper array.

Code example:

If we have a render element, and we need to pass the class 'bar' as an attribute for the theme wrapper for that element:

Before (D7):

<?php
array(
 
'#theme' => 'image',
 
'#attributes' => array('class' => 'foo'),
 
'#theme_wrappers' => array('container', 'custom_container'),
 
'#wrapper_attributes' => array('class' => 'bar'),
);
?>

After (D8):

<?php
array(
 
'#theme' => 'image',
 
'#attributes' => array('class' => 'foo'),
 
'#theme_wrappers' => array(
   
'container' => array(
     
'#attributes' => array('class' => 'bar'),
    ),
   
'custom_container' => array(
     
'#attributes' => array('class' => 'baz'),
    ),
  ),
);
?>

The array syntax is entirely optional and using a string as in D7 will work and just use the same #attributes as the theme hook.

Impacts: 
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done