You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 13, 2026. It is now read-only.
How to use shorthand syntax outside of patternlab itself? #54
I was just wondering if there was any interest in trying to go further and make the pattern partial loader itself available to consumers such as Drupal? I've done a simple PoC that seems to work for me:
pattern-lab-php-path-src-exporter: A PL listener that dumps the pattern paths data (ie the second argument to \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternPartialLoader::__construct()) to a file.
patternlabloader: A Drupal module that extends PatternPartialLoader to read the location of the pattern paths data file from the theme info file, and use it to construct the loader.
I'm quite new to Pattern Lab, maybe there's a better way to do this? At the moment a pain point is obviously that to get the partial loader and utility class you need patternengine-twig which needs core + deps, and really this is all for two classes: \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternPartialLoader and \PatternLab\PatternEngine\Util.
Would there be any chance we could grab the pattern partial loader without the rest of pattern lab? Any advice/suggestions?
@andriokha out of curiosity, have you looked into using Twig namespaces to basically get the same outcome (shorter Twig template paths + a little less brittle integrations if folder names change), but using a standard that Pattern Lab and Drupal (and any other system that speaks Twig for that matter) can understand?
Ex. {% include “@bolt-components-button/button.twig” %}
There’s been a ton of progress already made on this integration approach in the Pattern Lab / Drupal community (plugins, examples, modules, etc) if this fits the bill!
hey @sghoweri, thanks so much for your suggestion. When you put it like that, I start to see why maybe people haven't been working on getting this done (:
I was particularly hoping to be in a situation where unhiding a pattern wouldn't cause code churn (ie having to update the filename everwhere it's included). IIUC using a Twig namespace wouldn't help me there? Also there's a chance we'll be moving away from PHP and/or Twig in the future but stick with PL so I thought it might be neat to have something compatible between them. I guess it's a bit of a niche need (:
Activity
andriokha commentedon Apr 12, 2019
Connected issue on drupal.org: Support same including patterns like Pattern Lab
sghoweri commentedon Apr 24, 2019
@andriokha out of curiosity, have you looked into using Twig namespaces to basically get the same outcome (shorter Twig template paths + a little less brittle integrations if folder names change), but using a standard that Pattern Lab and Drupal (and any other system that speaks Twig for that matter) can understand?
Ex.
{% include “@bolt-components-button/button.twig” %}There’s been a ton of progress already made on this integration approach in the Pattern Lab / Drupal community (plugins, examples, modules, etc) if this fits the bill!
andriokha commentedon Apr 25, 2019
hey @sghoweri, thanks so much for your suggestion. When you put it like that, I start to see why maybe people haven't been working on getting this done (:
I was particularly hoping to be in a situation where unhiding a pattern wouldn't cause code churn (ie having to update the filename everwhere it's included). IIUC using a Twig namespace wouldn't help me there? Also there's a chance we'll be moving away from PHP and/or Twig in the future but stick with PL so I thought it might be neat to have something compatible between them. I guess it's a bit of a niche need (:
Thanks again for your time!