Change record status: 
Project: 
Introduced in branch: 
8.3.x
Introduced in version: 
8.3.0
Description: 

Previously it was only possible to work with existing Attribute objects within a Twig template. Now you can create new Attribute objects using the create_attribute() function inside a Twig template. These objects can then be manipulated just like other Attribute objects coming into the Twig template.

Examples:

{% set my_attribute = create_attribute() %}
{%
  set my_classes = [
    'kittens',
    'llamas',
    'puppies',
  ]
%}
<div{{ my_attribute.addClass(my_classes).setAttribute('id', 'myUniqueId') }}>
  {{ content }}
</div>
<div{{ create_attribute({'class': ['region', 'region--header']}) }}>
  {{ content }}
</div>
Impacts: 
Module developers
Themers