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_admin_block_content
template_preprocess_status_report
template_preprocess_system_themes_page
Twig Templates Modified
admin-block-content.html.twig
seven/templates/admin-block-content.html.twig
status-report.html.twig
system-themes-page.html.twig
Comment | File | Size | Author |
---|---|---|---|
#18 | 2329851-18.patch | 8.94 KB | Jolidog |
#16 | 2329851-16.patch | 8.94 KB | Jolidog |
#13 | 2329851-13.patch | 8.94 KB | lauriii |
#13 | interdiff-2329851-10-13.txt | 662 bytes | lauriii |
Comments
Comment #1
davidhernandezComment #2
lanchez CreditAttribution: lanchez commentedComment #3
lanchez CreditAttribution: lanchez commentedThis patch is pretty much doing what was needed. Some classes were left behind in template_preprocess_system_themes_page in screenshots and links theme arrays. I don't really know what to do with that kind of usage situation.
Comment #4
star-szrThanks @lanchez, this was a tricky one. Here's an initial review. My overall feeling is I think we may want to scale back a bit (mostly thinking of the status report) but if other folks are on board that's fine with me.
Why not
$variables['compact'] = $compact;
here? system_admin_compact_mode() returns a boolean.$state didn't go through a CSS-ifier before, not sure it should after.
I think we can lose the comma at least.
Maybe "This can be one of:" and the list items should use hyphens instead of asterisks per https://www.drupal.org/node/1354#lists.
I think the code comment here confused me, if we want to document this I think it should be a complete sentence explaining the array. Should be no space between the array key and the colon per Twig coding standards: http://twig.sensiolabs.org/doc/coding_standards.html
Extra space between
<div
and{{
here.Comment #5
lanchez CreditAttribution: lanchez commentedThanks for review!
I will make another patch, but one comment on system_admin_compact_mode(). It does not work right right now, since it really returns the value of the cookie (string). So no boolean there and thats why the workaround is in place. The D7 version of the function works fine.
Comment #6
lanchez CreditAttribution: lanchez commentedI did a few modifications:
1. Didn't yet change that yet -> could someone confirm if system_admin_compact_mode() works as intended or not?
2. Removed clean_class
3. Fixed comment to: - compact: True if compact mode is turned on.
4/5. Removed whole array. I don't even remember why I did it that way. Now it just prints severity_status|clean_class
6. Removed space.
Comment #7
star-szr@lanchez, thanks. That's looking much better to me! For #1 adding a code comment to explain would be good for the scope of this issue and we can check for an existing issue or file a new one for the incorrect behaviour/docs.
I really like the the "True if…" one better! Can we make them both consistent please?
Doesn't this need to be requirement.severity_status? Again, not sure if we need clean_class in this case.
Comment #8
lanchez CreditAttribution: lanchez commentedDoh, stupid mistakes from me :)
I fixed the comment and severity_status class (and removed the clean_class, since its a manual string in code). Also added the comment you suggested.
Comment #9
lauriiiNice work on the patch!
What are we trying to tackle exactly with this change? I think we instead need to fix the function or documentation for the function.
Comment #10
lauriiiComment #11
mikl CreditAttribution: mikl commentedReviewed, nice work :)
Comment #13
lauriiiComment #14
sqndr CreditAttribution: sqndr commentedChange to: is_default: Boolean indicating whether the theme is the default theme not.
I would change the second documentation part to be the same as the first one. That would make sense, right?
True if compact mode is turned on.
would then just becomeBoolean indicating whether compact mode is turned on or not.
, like the first message.Comment #15
sqndr CreditAttribution: sqndr commentedTagging this as needs works again, removing some of the tags and adding the Novice tag, since fixing the remaining things would be a novice task.
Comment #16
Jolidog CreditAttribution: Jolidog commentedPatch Reroll and comments fixed.
Comment #17
sqndr CreditAttribution: sqndr commentedThanks Jolidog for fixing the documentation. I've got to nitpick a little more… The or should be on the next line, according to the Drupal coding standards; since it's exceeding the 80 characters per line limit.
Comment #18
Jolidog CreditAttribution: Jolidog commentedThanks sqndr for spotting this, "or" is now on the next line.
Comment #19
mbroere CreditAttribution: mbroere commentedDoing manual review whit Kaleidoscope.Comment #20
lauriiiComment #21
LewisNymanI manually reviewed the patch to verify the classes still appear where they should and nothing is broken. BANANA!
Comment #22
alexpottCommitted 79f952a and pushed to 8.0.x. Thanks!
Comment #25
lauriiiPutting back to fixed state