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_status_messages
template_preprocess_feed_icon
template_preprocess_field_multiple_value_form

Twig Templates Modified

status-messages.html.twig
feed-icon.html.twig
field-multiple-value-form.html.twig

Files: 
CommentFileSizeAuthor
#3 2329853-3.patch1.59 KBCottser
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 77,598 pass(es). View

Comments

davidhernandez’s picture

Issue tags: +FUDK
Cottser’s picture

Assigned: Unassigned » Cottser

Not sure there's much we can do with template_preprocess_field_multiple_value_form() because it's within a #type table, but I'll work on a patch for the other two.

Cottser’s picture

Assigned: Cottser » Unassigned
Status: Active » Needs review
FileSize
1.59 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 77,598 pass(es). View

Here's a start.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Tested this and classes still seems to be there how supposed to. Code seems to be what it should be and all the possible classes have been removed from preprocesses.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Was a bit confused because template_preprocess_status_messages doesn't add classes and is not touched by the patch. So the messages template change is just bringing it up to standards.

Committed/pushed to 8.0.x, thanks!

  • catch committed a1a0cc8 on 8.0.x
    Issue #2329853 by Cottser: Move miscellaneous theme.inc classes from...
Cottser’s picture

You're right, that wasn't really following the issue title, just aiming for consistency. Thanks @catch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.