This is a meta issue to track proposed changes to template_preprocess().

Main motivations:

Issues:
#1938430: Don't add a default theme hook class in template_preprocess()
#1982024: Lazy-load Attribute objects later in the rendering process only if needed
#1982020: Add static caching to drupal_html_class()
#2340341: Move template_preprocess, _template_preprocess_default_variables into services

Comments

star-szr’s picture

Issue summary: View changes

Add more issues

star-szr’s picture

Issue summary: View changes

Updated issue summary.

c4rl’s picture

Per #1938430-18: Don't add a default theme hook class in template_preprocess(), my original intention of that issue was to remove template_preprocess() entirely, and I would still like that to happen.

Frankly, I think #1982024: Lazy-load Attribute objects later in the rendering process only if needed perpetuates an anti-pattern. What do we gain by assuming every template contains `attributes,` `title_attributes,` and `content_attributes` whilst any other presence of another Attribute object in a template would require invocation anyway via `new Attribute` in a subsequent preprocessor?

Really, I'm curious of what would be wrong with invoking `new Attribute` on a case-by-case basis. I think assuming that every templates wants these goes some of the Principles we established at BADCamp 2012.

c4rl’s picture

Issue summary: View changes

Updated issue summary.

joelpittet’s picture

Issue summary: View changes

I agree with @c4rl in #1 entirely. Though undoing that "anti-pattern" is harder than it sounds due to the prevalence of NestedArray::mergeDeepArray. I got half way there with this issue #2108771: Remove special cased title_attributes and content_attributes for Attribute creation.

And regarding removing template_preprocess(). It will need to be done delicately so we don't break things but that would be a nice thing to do as well:)

jiv_e’s picture

jiv_e’s picture

Issue summary: View changes
joelpittet’s picture

Version: 8.0.x-dev » 9.x-dev

Likely 9.x

catch’s picture

Status: Active » Closed (duplicate)

#2340341: Move template_preprocess, _template_preprocess_default_variables into services is the only remaining issue from the summary, and is in progress against 8.3.x, so closing this.

Version: 9.x-dev » 9.0.x-dev

The 9.0.x branch will open for development soon, and the placeholder 9.x branch should no longer be used. Only issues that require a new major version should be filed against 9.0.x (for example, removing deprecated code or updating dependency major versions). New developments and disruptive changes that are allowed in a minor version should be filed against 8.9.x, and significant new features will be moved to 9.1.x at committer discretion. For more information see the Allowed changes during the Drupal 8 and 9 release cycles and the Drupal 9.0.0 release plan.