Currently, BuildProcessor_Container and other classes provide an API of mutable setters to set html attributes.
This is implemented using the HtmlTagTrait and HtmlAttributesTrait.

We should keep the setters for BC reasons, but provide withers instead.

We should also allow to attach CSS, JS and libraries.

Currently in HtmlTagTrait and HtmlAttributesTrait we store the $attributes array and the $tagName as private properties.
Instead, we could introduce a stub $element property which would store everything, in the format of a Drupal render element.

I am a bit skeptical about traits, because they fail to encapsulate anything from the classes that use them.
But I think for this purpose they are still the best fit.

Comments

donquixote created an issue.