Theming with Bundle Classes, Layout builder and Twig

Daniel Veza

PreviousNext

Using Drupal since 2014

Bundle classes

One of the best new additions to core

Keep business logic in a single place per entity

Code sharing, interfaces and traits

Better testability

Twig integration & less preprocesses

Layout Builder

Editorial control of layout

Drag and drop interface

Twig
Life Story block
27 lines of HTML, 10 divs for 3 fields
New Requirement is in!

0-5 Minutes - Short

6-10 Minutes - Medium

11+ Minutes - Long

Goodbye Manage Display

block--bundle--life-story.html.twig

umami_override.theme

Lets compare

Where are we now?

We've met the new requirement

Code is in the theme

Testing is difficult

Testing

Advanced

Add a base class per entity

Traits & code sharing

Design systems & Real world examples

Base classes per entity

Traits

Design systems & Real world examples

Bundle classes resources:

Layout Builder modules used:

  • Layout Builder claro
  • Layout Builder restrictions
  • Layout Builder lock
  • Layout Builder section classes
  • Layout Builder default blocks

Questions