Skip to content

Twig namespaces

Choose a tag to compare

@illepic illepic released this 28 Dec 19:16
· 95 commits to master since this release

Adding new patternLab.twigNamespaces functionality for more resilient and flexible include paths. Can now just do @molecules/filename.twig instead of @molecules/path/to/filename.twig. Injects config into Drupal theme file and Pattern Lab config file; requires both the Drupal Component Libraries module and the Pattern Lab Twig Namespaces plugin.

Example config:

patternLab: {
  twigNamespaces: {
    addToDrupalThemeFile: true,
    sets: ['base', 'atoms', 'molecules', 'organisms', 'templates', 'pages'].map((item, i) => ({
      namespace: item,
      paths: [`source/_patterns/0${i}-${item}`],
    }))
  }
},
drupal: {
  themeFile: 'patternlab.info.yml'
}