Feeds

Author

Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Jan 11 2021
Jan 11

When developing or maintaining a Drupal theme, there is often a need to understand why a theme needed to override a given template. A diff of the template in the active theme compared to the template in the base theme would make this easy to understand. A drush command that found the template files for you and output a diff would solve this quite nicely.

Template Diff

The Template Diff module does just that. It provides a drush command that accepts a template name and will display the diff between two specified themes. If no theme is specified it defaults to comparing the active theme and its base theme.

Examples

Compare the active theme and its base theme:

drush template_diff:show views-view

Compare "foo_theme" vs "bar_theme":

drush template_diff:show views-view foo_theme bar_theme

Compare "some_theme" and its base theme:

drush template_diff:show views-view some_theme

The output will look something like this:

$ drush template_diff:show views-view
 [notice] Comparing chromatic (active theme) and stable (base theme).
- stable
+ chromatic
@@ @@
 {#
 /**
  * @file
- * Theme override for main view template.
+ * Default theme implementation for main view template.
  *
  * Available variables:
  * - attributes: Remaining HTML attributes for the element.
- * - css_name: A CSS-safe version of the view name.
+ * - css_name: A css-safe version of the view name.
  * - css_class: The user-specified classes names, if any.
  * - header: The optional header.
  * - footer: The optional footer.
…

If you have ideas on how to improve this, submit an issue so we can make understanding template overrides even easier.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web