Skip to main content

Retrofit's next milestone: Drupal 7 theme support

Published on

It has been a little over a month since I announced Retrofit. The project provides a compatibility layer to allow legacy Drupal 7 code to run within a Drupal 10 code base. Since Retrofit was first released, I was able to add support for theme functions and PHPTemplate template files so that existing hook_theme declarations work with minimal modifications. Since then, I have been trying to decide on the next milestone for the project. What compatibility support can Retrofit provide to unlock the most benefit to organizations upgrading from Drupal 7? Themes!

Theme support in Retrofit

In my experience, it has generally been a pattern that any site upgrade entails a redesign. But, that has been because the upgrade was treated as a re-platform versus a software upgrade. Retrofit is meant to make the transition off of Drupal 7 as an upgrade and not a re-platform.

One major challenge surrounds enforcing asset libraries for attaching CSS and JavaScript to the page. In Drupal 7, developers could call drupal_add_css and drupal_add_js to attach CSS and JavaScript files to the page arbitrarily. Themes defined their CSS and JavaScript files in their info file. Retrofit must dynamically create and register an asset library from these definitions

Once that is resolved, I imagine there will be a handful of smaller issues before themes are "just working" when using Retrofit. I will need to address the fact there is no longer a "post-process" hook for rendered output, only "pre-process." I'll need to find a way to invoke those hooks.

However, Alex Bronstein (effulgentsia) raised an important issue that Retrofit must address: securely running Drupal 7 templates and themes. Drupal 8 replaced PHPTemplate with the Twig templating system. Twig features automatic output-escaping, making it far more secure against XSS scripts. Drupal 7 would escape any variables known to have come from user-based input. Retrofit will need to provide a solution for this.

Support Retrofit's development

Are you looking to use Retrofit? Do you believe it'd solve your organization's upgrade from Drupal 7 to Drupal 10? Consider becoming a GitHub Sponsor!

I am also evaluating a paid support queue, making it easier for organizations to get support when using Retrofit. This allows privately discussing system code to help build Retrofit's compatibility layers. If interested, contact me!

I'm available for one-on-one consulting calls – click here to book a meeting with me 🗓️