Pattern Lab and Drupal 8 theme integration update

A lot has happened since my first Pattern Lab post in January. The eve of DrupalCon New Orleans 2016 seemed to me like a good time for a summary.

Drupal Edition of Pattern Lab, Drupal StarterKits

No more dubious forks! Most of my pull requests were merged into the official repository by Dave Olsen, the lead developer of Pattern Lab.

Evan Lovely, Christopher Bloom and Anne Sturdivant from Phase2 got in touch, and Dave gave us the honour of being the first members of a new Pattern Lab Drupal team.

New official Pattern Lab projects were created: the Drupal Edition of Pattern Lab, a Minimal Drupal StarterKit and a Demo Drupal StarterKit.

If you have Composer installed all you need to do to try out the Drupal edition is run

composer create-project pattern-lab/edition-drupal-standard

Pattern Lab chat rooms opened

To help coordinate all this activity, chat rooms were opened on Gitter. There is a general chat room and separate chat rooms for the PHP and Node versions of Pattern Lab. Drupal stuff is mostly discussed in the PHP room. Everyone is welcome to follow and join in the discussion!

Support for Twig namespaces

Twig PatternEngine now supports Twig namespaces for the top-level pattern folders. Includes like @atoms/pattern/path.twig are now possible, and they will work on Drupal too when using the Component Libraries module, for example.

Plugin access to Twig_Environment

This is a big one! Twig PatternEngine now fires events when Twig loaders are initialized and plugins have access to the respective Twig_Environment. This makes it possible for plugins to register Twig extensions.

New version of Data Transform Plugin

As a consequence of Twig_Environment being accessible to plugins, PatternDataVisitor was moved to Data Transform Plugin. Specific handling of Drupal's Attribute class could then be added for a new release of Data Transform Plugin. Workarounds for including templates that manipulate Attribute objects are no longer needed!

The question of Drupal's Twig extensions

It soon came apparent that duplicating the decoupled 'dummy versions' of Drupal's Twig extensions in different StarterKits was not practical or desirable. A Drupal Twig Components Plugin was created to avoid duplication and make updates simpler.

However, the extensions contained in the plugin are still written in the Pattern Lab specific auto-load style. Now that it is possible, creating a standard Twig_ExtensionInterface based extension seems to be the logical next step.

In April a major component-based rendering issue was opened on drupal.org by Wim Leers. Based on the enthusiastic response it is likely that the future of Drupal will include decoupled Twig.js compatible components. A strategy for Drupal's Twig functions, and particularly Attribute, is needed.

To me this looks like an opportunity to create an official stand-alone version of Drupal's Twig extensions. I opened an issue about it and am looking forward to helping make something like that happen.

DrupalCon New Orleans

The buzz around atomic/modular/pattern/component based design seems to keep on growing. The schedule for DrupalCon New Orleans includes at least three sessions and one BoF on Pattern Lab or related topics:

A lot has happened since my first Pattern Lab post in January. The eve of DrupalCon New Orleans 2016 seemed to me like a good time for a summary.