Upcoming

Accommodating Drupal In Your Components

February 24, 2018

While Drupalers are rejoicing at these exciting advances allowing newfound front end freedoms, there are still a few hoops to be aware of in order to make the most of Drupal, especially for a newcomer who might be eager to shove aside a lot of what Drupal provides. ...things that are easily dismissed in a component-driven approach, like letting Drupal fully render fields, can cause headaches further on if they’re ignored, and make life difficult when it comes to keeping your front end forward-compatible with Drupal.

The UI Patterns module really does solve many of the problems outlined in this post, so my preference is to embrace that approach and leave these complicated presenter templates behind. But for those who haven’t embraced UI Patterns, this post really is essential.

When explaining some of the gotchas with this approach, I often use images as a simple example. Creating a component from scratch the instinct is often to pass in src and alt values as variables to get the cleanest markup possible. You can get that stuff out of Drupal, but it really is a pain. You’re better off just using the image markup Drupal renders, even if it isn't exactly as clean as you want it to be. Sometimes not fighting this battle at all is the right way to go. But if you want the perfect markup this post has everything you need to do it the right way.