A sample Drupal 8 site with a Pattern Lab Twig powered theme.
All commands starting with
bash are run from root of repo; all that start with
drupal are ran from
- node js installed - supported node versions: 0.12.x, 4.x, 5.x, and 6.x using npm 2.x or 3.x.
When it asks if you want to merge or replace stuff, select merge.
Run Drupal & Pattern Lab Servers
In two Terminal tabs, run:
composer run server --timeout=0
../vendor/bin/drupal cr all
Theme & Pattern Lab
All commands are run from root of theme in
npm install was ran in
site-setup.sh script, run
npm install if you don't see
node_modules/ or have errors.
To compile theme (CSS & Pattern Lab):
npm run compile
To execute watches on Scss and Pattern Lab along with a server for Pattern Lab, run:
How to build your own
Simple, pre-packaged Drupal Theme with Twig Pattern Lab
drush dl patternlab
Custom configured Drupal Theme with Twig Pattern Lab
Here's a collection of the tools used to build this site; go make something cool with them!
- Pattern Lab 2.0 - Drupal Edition - this collection of tools super charges what could be done with Pattern Lab 1.0 and is made up of these pieces:
- Twig Engine for Pattern Lab - instead of the traditional Mustache engine in Pattern Lab 1.0, this uses Twig, which is much more powerfule, and is template language in Drupal 8!
- Drupal Twig Components plugin - this adds extra functionality to Pattern Lab's Twig Engine, and let's use the essential
transTwig Functions; among many more!
- Data Transform plugin - this super charges the JSON/YAML Pattern Sidecar data files to effectively let you pre-process data before rendering Twig templates. Incredibly powerful & flexible. Made by the awesome Aleksi Peebles.
The above tools give us a Twig powered, Drupal-aware Pattern Lab and can be spun up with:
composer create-project pattern-lab/edition-drupal-standard
After making changes, run
../vendor/bin/drupal config:export -y and commit the files. If you just pulled or are deploying, run
../vendor/bin/drupal config:import -y to pull configuration changes present in the yaml files in
web/sites/default/config/sync/ into the database. Very similar to Features in Drupal 7.
Install Drupal Modules
To install a new Drupal module, run this:
composer require drupal/MODULE_NAME:8.*
After enabling, do a
../vendor/bin/drupal config:export -y.
Who's behind this?
Built with love at Phase2 by Evan Lovely, Anne Sturdivant, and Chris Bloom. Most of the work to make this possible happened over at the Pattern Lab GitHub org with collaboration from Dave Olsen & Aleksi Peebles. Special thanks to Kellye Rogers and Frank Febbraro for supporting this internal project and wanting to share it with the community!