Move classes out of the preprocess functions and into the Twig templates. Use the addClass() attribute method to add classes in the template. Use the clean_class filter to filter class names, if necessary. Maintain all existing functionality and ensure all existing class names are still in the markup, even ones that are inherited.
See the following issues for more detailed examples:
#2217731: Move field classes out of preprocess and into templates
#2254153: Move node classes out of preprocess and into templates
See this change record for information about using the addClass() method:
https://www.drupal.org/node/2315471
See this change record for more information about the phase 1 process of moving class from preprocess to templates:
https://www.drupal.org/node/2325067
Preprocess Functions Modified
template_preprocess_update_report
template_preprocess_update_project_status
Twig Templates Modified
update-report.html.twig
update-project-status.html.twig
Comment | File | Size | Author |
---|---|---|---|
#14 | update-project-name-2.png | 72.57 KB | DickJohnson |
#14 | update-classes.png | 250.13 KB | DickJohnson |
#10 | interdiff.txt | 604 bytes | star-szr |
#10 | 2329829-10.patch | 5.11 KB | star-szr |
Comments
Comment #1
davidhernandezComment #2
dstorozhukComment #3
star-szr@dstorozhuk - I don't want to rush you but have you started work on this? I'm just making sure we get patches on all these sub-issues to keep our momentum up :)
If you won't have time you can unassign. I'll give you a couple days to respond as to whether you are working on this or not. Thanks!
Comment #4
star-szrUp for grabs.
Comment #5
lauriiiComment #6
lauriiiComment #7
Wim LeersThese are extra classes, not extra attributes.
Off-topic: how do you set extra attributes in Twig? Doesn't seem to be supported?
Comment #8
lauriiiComment #9
davidhernandez@Wim, #2325517: Add methods for adding/removing attributes (not classes) on Attribute objects
Comment #10
star-szrThis is the only thing I could find:
new Attribute()
per https://www.drupal.org/coding-standards#constructors.Rolled in here. Manually tested and RTBC. Nice work!
Comment #11
webchickCommitted and pushed to 8.x. Thanks!
Comment #14
DickJohnson CreditAttribution: DickJohnson commentedWhile I was working on #2408499: Rewrite update components inline with our CSS standards I noticed that we still have classes at least in core/modules/update/src/Form/UpdateManagerUpdate.php
example:
I also noticed that a lot of markup is coming from somewhere else than templates, so when we start to add new classes to table-elements I'm pretty sure we will get even more classes to non-template files.
As I tried to point out there: https://www.drupal.org/node/2408499#comment-9591331 testing these templates, CSS and which classes are being used and where is relatively difficult, so we should double check things.
Comment #15
davidhernandezIf there is something we missed, assuming it isn't gigantic, add it here #2407565: Consensus Banana Phase 1, cleanup and we'll try to get it all cleaned up in one patch.
Comment #16
star-szr@DickJohnson - in general we knew going into this (banana) that we wouldn't be eliminating all classes. They are coming from too many places. But we can reduce at least. Thanks for looking into that!