Skip to content

Instantly share code, notes, and snippets.

@carlwiedemann
Last active December 12, 2015 13:39
Show Gist options
  • Save carlwiedemann/4780229 to your computer and use it in GitHub Desktop.
Save carlwiedemann/4780229 to your computer and use it in GitHub Desktop.

Summary

I had a look at calls to _preprocess_html and _process_html and what they do in core. I've listed what we need to provide and a summary of existing implementations.

It seems that everything existing in core can be potentially solved by:

  • Providing the ability to add/modify attributes to the <body> tag and the <html> tag. Most of the time, it's class attributes, but RDFa will have other needs.
  • Better asset management (CSS/JS). Preprocessors sometimes call drupal_add_js, etc. We're already talking about this in core.
  • Providing an API for theme hook/template suggestions outside of preprocessors. (There's an issue for this)
  • Providing the ability to add/modify <link> and <meta> tags, and the <title> tag, all within <head>. This is on sdboyer's radar.
  • Resolving apparent conflicts with contextual links and views contextual links. Now that views is out of contrib, we can probably fix this better. Arguably, contextual links should be pure JS? Not sure what work has been done here yet.

Existing implementations

Calls to template_preprocess

./core/includes/theme.inc

Setup some default variables and arbitrary zebra-striping. Wondering how necessary _template_preprocess_default_variables() really is. Arguably most things here are unnecessary to the html template.

./core/modules/contextual/contextual.module

Sets up some classes and title suffix things, arguably should be done in pure JS, and likely not applicable to the html template.

Calls to template_process

./core/modules/rdf/rdf.module

Sets up any RDFa attributes and metadata attributes. We really need a better API for this than _process functions layer.

Calls to template_preprocess_html

./core/includes/theme.inc

Adds a class attribute to <body>:

  • front/not-front
  • logged-in/not-logged-in
  • Sidebar-influenced classes
  • Theme hook suggestion name classes

Adds a class attribute to <html>:

  • Node type name
  • Language and rtl/ltr

Adds a <link> tag for favicon

Populates the <title> tag

Adds <meta> tags for mobile/responsive

Scans for theme hook suggestions

./core/modules/overlay/overlay.module

Adds a class attribute to <body>

./core/modules/rdf/rdf.module

Adds attributes to <html>

./core/modules/views/views.module

Something to do with a conflict with Contextual links

./core/themes/bartik/template.php

Adds a class attribute to <body>

./core/themes/seven/template.php

Adding normalize CSS library and IE-specific CSS

Calls to template_process_html

./core/includes/theme.inc

Renders, adds assets, libraries. This can be refactored.

./core/modules/color/color.module

Has _color_html_alter that seems to depend on some other _process_html to add assets. This can be refactored.

./core/themes/bartik/template.php

A call to _color_html_alter as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment