From 6914f61aec14f6148bbc6df12df7e6b452cefdbc Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Tue, 25 Oct 2016 14:02:02 -0700 Subject: [PATCH] updating to use new twig namespace approach --- gulpconfig.js | 25 ++++++++ package.json | 2 +- pattern-lab/composer.json | 3 +- pattern-lab/composer.lock | 58 ++++++++++++++++++- pattern-lab/config/config.yml | 43 +++++++++++++- pattern-lab/config/listeners.json | 2 +- patternlab.info.yml | 33 +++++++---- .../caption-grid-block.twig | 6 +- .../site/site-header/site-header.twig | 2 +- .../_patterns/04-templates/site-layout.twig | 4 +- source/_patterns/05-pages/homepage.twig | 4 +- .../block--system-branding-block.html.twig | 2 +- templates/node--teaser.html.twig | 2 +- 13 files changed, 158 insertions(+), 28 deletions(-) diff --git a/gulpconfig.js b/gulpconfig.js index a9c11c411f..2730583819 100644 --- a/gulpconfig.js +++ b/gulpconfig.js @@ -84,6 +84,30 @@ module.exports = { injectFiles: [], injectBower: true, bowerBasePath: './', + twigNamespaces: { + addToDrupalThemeFile: true, + sets: [ + { + namespace: 'base', + paths: ['source/_patterns/00-base'] + }, { + namespace: 'atoms', + paths: ['source/_patterns/01-atoms'] + }, { + namespace: 'molecules', + paths: ['source/_patterns/02-molecules'] + }, { + namespace: 'organisms', + paths: ['source/_patterns/03-organisms'] + }, { + namespace: 'templates', + paths: ['source/_patterns/04-templates'] + }, { + namespace: 'pages', + paths: ['source/_patterns/05-pages'] + }, + ] + }, scssToJson: [ { src: 'source/_patterns/00-base/01-colors/_color-vars.scss', @@ -172,6 +196,7 @@ module.exports = { }, drupal: { enabled: false, + themeFile: 'patternlab.info.yml', // when these files change watch: [ 'templates/**', diff --git a/package.json b/package.json index 1b72ee44a4..c905a07c50 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "babel-preset-es2015": "^6.6.0", "bower": "^1.7.9", "gulp": "gulpjs/gulp#4.0", - "p2-theme-core": "^9.2.1", + "p2-theme-core": "^9.3.1", "stylelint-scss": "^1.3.4", "rc": "^1.1.6" }, diff --git a/pattern-lab/composer.json b/pattern-lab/composer.json index 4ac2c1ff02..eec5cab4b4 100644 --- a/pattern-lab/composer.json +++ b/pattern-lab/composer.json @@ -28,7 +28,8 @@ "pattern-lab/styleguidekit-twig-default": "^3.0.0", "pattern-lab/drupal-twig-components": "^2.0.0", "aleksip/plugin-data-transform": "^1.0.0", - "pattern-lab/plugin-faker": "^2.0" + "pattern-lab/plugin-faker": "^2.0", + "evanlovely/plugin-twig-namespaces": "^1.0" }, "scripts": { "post-install-cmd": [ diff --git a/pattern-lab/composer.lock b/pattern-lab/composer.lock index 8021d23a65..db2090630f 100644 --- a/pattern-lab/composer.lock +++ b/pattern-lab/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e73f6be5c2d5b998248e57203b5c9688", - "content-hash": "3002c89ca6e716101bc2042f2a033939", + "hash": "e38759cb09f748c2681564dfd23b337b", + "content-hash": "8df47b4e1d37b3f04052d6e5443a0a7d", "packages": [ { "name": "alchemy/zippy", @@ -181,6 +181,60 @@ ], "time": "2015-04-14 22:21:58" }, + { + "name": "evanlovely/plugin-twig-namespaces", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/EvanLovely/plugin-twig-namespaces.git", + "reference": "d12f8d6ff2624ea81beccb134b315587350a6fca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/EvanLovely/plugin-twig-namespaces/zipball/d12f8d6ff2624ea81beccb134b315587350a6fca", + "reference": "d12f8d6ff2624ea81beccb134b315587350a6fca", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "type": "patternlab-plugin", + "extra": { + "patternlab": { + "config": { + "plugins": { + "twigNamespaces": { + "enabled": false, + "roots": [] + } + } + } + } + }, + "autoload": { + "psr-0": { + "PatternLab\\TwigNamespaces": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Evan Lovely", + "homepage": "http://evanlovely.com", + "role": "Lead Developer" + } + ], + "description": "Twig Namespaces for Pattern Lab", + "homepage": "http://patternlab.io", + "keywords": [ + "pattern lab", + "twig" + ], + "time": "2016-10-12 16:53:30" + }, { "name": "fzaninotto/faker", "version": "v1.6.0", diff --git a/pattern-lab/config/config.yml b/pattern-lab/config/config.yml index 8518efa5f9..d4c8c7d0e1 100644 --- a/pattern-lab/config/config.yml +++ b/pattern-lab/config/config.yml @@ -24,7 +24,9 @@ ishMinimum: '240' ishMaximum: '2600' ishControlsHide: - hay -lineageMatch: '{%([ ]+)?include( |\()["\']([A-Za-z0-9-_]+)["\'](\))?(.*)%}' +lineageMatch: >- + {%([ ]+)?include( + |\()["\']([A-Za-z0-9-_]+)["\'](\))?(.*)%} lineageMatchKey: 3 patternExtension: twig twigDebug: true @@ -42,3 +44,42 @@ plugins: faker: enabled: true locale: en_US + twigNamespaces: + enabled: true + namespaces: + base: + paths: + - ../source/_patterns/00-base + - ../source/_patterns/00-base/01-colors + - ../source/_patterns/00-base/animations/01-transitions + - ../source/_patterns/00-base/breakpoints + - ../source/_patterns/00-base/grids + - ../source/_patterns/00-base/spacing + - ../source/_patterns/00-base/utilities/borders + atoms: + paths: + - ../source/_patterns/01-atoms + - ../source/_patterns/01-atoms/01-typography/fonts + - ../source/_patterns/01-atoms/01-typography/headings + - ../source/_patterns/01-atoms/01-typography/lists + - ../source/_patterns/01-atoms/01-typography/text + - ../source/_patterns/01-atoms/buttons + - ../source/_patterns/01-atoms/images + molecules: + paths: + - ../source/_patterns/02-molecules + - ../source/_patterns/02-molecules/branding + - ../source/_patterns/02-molecules/caption-block + organisms: + paths: + - ../source/_patterns/03-organisms + - ../source/_patterns/03-organisms/grids/caption-grid-block + - ../source/_patterns/03-organisms/site/site-footer + - ../source/_patterns/03-organisms/site/site-header + templates: + paths: + - ../source/_patterns/04-templates + - ../source/_patterns/04-templates/content-types + pages: + paths: + - ../source/_patterns/05-pages diff --git a/pattern-lab/config/listeners.json b/pattern-lab/config/listeners.json index 63e843d5cf..df0570d211 100644 --- a/pattern-lab/config/listeners.json +++ b/pattern-lab/config/listeners.json @@ -1 +1 @@ -{"listeners":["\\aleksip\\DataTransformPlugin\\PatternLabListener","\\PatternLab\\Faker\\PatternLabListener"]} \ No newline at end of file +{"listeners":["\\aleksip\\DataTransformPlugin\\PatternLabListener","\\PatternLab\\Faker\\PatternLabListener","\\PatternLab\\TwigNamespaces\\PatternLabListener"]} \ No newline at end of file diff --git a/patternlab.info.yml b/patternlab.info.yml index 5aa3c7696d..ed7c09c264 100755 --- a/patternlab.info.yml +++ b/patternlab.info.yml @@ -1,40 +1,49 @@ name: Pattern Lab Starter type: theme -description: 'A theme with Pattern Lab' +description: A theme with Pattern Lab base theme: stable core: 8.x - -# Libraries libraries: - patternlab/core - regions: header: Header - content: Content # the content region is required - sidebar_first: 'Sidebar first' + content: Content + sidebar_first: Sidebar first footer: Footer - -# MUST install `components` module: `drush dl components && drush en components -y` -# For compatibility with Pattern Lab templates; this list must -# always be the folders immediately under the `$sourceDir` patterns folder -# `$sourceDir` = defined in `pattern-lab/config/config.yml` under `sourceDir -# patterns folder = `$sourceDir` + `_patterns/` component-libraries: base: paths: - source/_patterns/00-base + - source/_patterns/00-base/01-colors + - source/_patterns/00-base/animations/01-transitions + - source/_patterns/00-base/breakpoints + - source/_patterns/00-base/grids + - source/_patterns/00-base/spacing + - source/_patterns/00-base/utilities/borders atoms: paths: - source/_patterns/01-atoms + - source/_patterns/01-atoms/01-typography/fonts + - source/_patterns/01-atoms/01-typography/headings + - source/_patterns/01-atoms/01-typography/lists + - source/_patterns/01-atoms/01-typography/text + - source/_patterns/01-atoms/buttons + - source/_patterns/01-atoms/images molecules: paths: - source/_patterns/02-molecules + - source/_patterns/02-molecules/branding + - source/_patterns/02-molecules/caption-block organisms: paths: - source/_patterns/03-organisms + - source/_patterns/03-organisms/grids/caption-grid-block + - source/_patterns/03-organisms/site/site-footer + - source/_patterns/03-organisms/site/site-header templates: paths: - source/_patterns/04-templates + - source/_patterns/04-templates/content-types pages: paths: - source/_patterns/05-pages diff --git a/source/_patterns/03-organisms/grids/caption-grid-block/caption-grid-block.twig b/source/_patterns/03-organisms/grids/caption-grid-block/caption-grid-block.twig index 7f45f9d75f..8c5864038a 100644 --- a/source/_patterns/03-organisms/grids/caption-grid-block/caption-grid-block.twig +++ b/source/_patterns/03-organisms/grids/caption-grid-block/caption-grid-block.twig @@ -5,7 +5,7 @@ } %} {% block gridItems %} - {% embed "@molecules/caption-block/caption-block.twig" with { + {% embed "@molecules/caption-block.twig" with { title: "Block 1", img: { landscape: "http://placeimg.com/640/360/tech" @@ -16,7 +16,7 @@ {% endblock %} {% endembed %} - {% embed "@molecules/caption-block/caption-block.twig" with { + {% embed "@molecules/caption-block.twig" with { title: "Block 2", img: { landscape: img.square @@ -28,7 +28,7 @@ {% endblock %} {% endembed %} - {% embed "@molecules/caption-block/caption-block.twig" with { + {% embed "@molecules/caption-block.twig" with { title: "Block 3" } %} {% block body %} diff --git a/source/_patterns/03-organisms/site/site-header/site-header.twig b/source/_patterns/03-organisms/site/site-header/site-header.twig index e554b49db3..2220673716 100644 --- a/source/_patterns/03-organisms/site/site-header/site-header.twig +++ b/source/_patterns/03-organisms/site/site-header/site-header.twig @@ -1,4 +1,4 @@ diff --git a/source/_patterns/04-templates/site-layout.twig b/source/_patterns/04-templates/site-layout.twig index c6c77be2ce..2c77277b68 100644 --- a/source/_patterns/04-templates/site-layout.twig +++ b/source/_patterns/04-templates/site-layout.twig @@ -1,7 +1,7 @@ -{% include "@organisms/site/site-header/site-header.twig" %} +{% include "@organisms/site-header.twig" %}
{% block content %}

Site Content Here

{% endblock %}
-{% include "@organisms/site/site-footer/site-footer.twig" %} +{% include "@organisms/site-footer.twig" %} diff --git a/source/_patterns/05-pages/homepage.twig b/source/_patterns/05-pages/homepage.twig index 081d54ca38..c998d1aa95 100644 --- a/source/_patterns/05-pages/homepage.twig +++ b/source/_patterns/05-pages/homepage.twig @@ -1,6 +1,6 @@ {% extends "@templates/site-layout.twig" %} {% block content %} - {% include "@organisms/grids/caption-grid-block/caption-grid-block.twig" %} - + {% include "@organisms/caption-grid-block.twig" %} + {% endblock %} diff --git a/templates/block--system-branding-block.html.twig b/templates/block--system-branding-block.html.twig index 243bb507d9..a557c6c1e1 100755 --- a/templates/block--system-branding-block.html.twig +++ b/templates/block--system-branding-block.html.twig @@ -15,7 +15,7 @@ #} {% block content %} - {% include "@molecules/branding/branding.twig" + {% include "@molecules/branding.twig" with { "url": path('') } diff --git a/templates/node--teaser.html.twig b/templates/node--teaser.html.twig index d967a8d6a0..d7f72cd273 100644 --- a/templates/node--teaser.html.twig +++ b/templates/node--teaser.html.twig @@ -64,7 +64,7 @@ */ #} -{% embed "@molecules/caption-block/caption-block.twig" +{% embed "@molecules/caption-block.twig" with { "title": label }