Skip to content

Commit

Permalink
updating to use new twig namespace approach
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanLovely committed Oct 25, 2016
1 parent 019c76f commit 6914f61
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 28 deletions.
25 changes: 25 additions & 0 deletions gulpconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -172,6 +196,7 @@ module.exports = {
},
drupal: {
enabled: false,
themeFile: 'patternlab.info.yml',
// when these files change
watch: [
'templates/**',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 2 additions & 1 deletion pattern-lab/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
58 changes: 56 additions & 2 deletions pattern-lab/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion pattern-lab/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion pattern-lab/config/listeners.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"listeners":["\\aleksip\\DataTransformPlugin\\PatternLabListener","\\PatternLab\\Faker\\PatternLabListener"]}
{"listeners":["\\aleksip\\DataTransformPlugin\\PatternLabListener","\\PatternLab\\Faker\\PatternLabListener","\\PatternLab\\TwigNamespaces\\PatternLabListener"]}
33 changes: 21 additions & 12 deletions patternlab.info.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="site-header">
{% include "@molecules/branding/branding.twig" %}
{% include "@molecules/branding.twig" %}
<h2>Site Header</h2>
</header>
4 changes: 2 additions & 2 deletions source/_patterns/04-templates/site-layout.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% include "@organisms/site/site-header/site-header.twig" %}
{% include "@organisms/site-header.twig" %}
<main class="site-content">
{% block content %}
<h2>Site Content Here</h2>
{% endblock %}
</main>
{% include "@organisms/site/site-footer/site-footer.twig" %}
{% include "@organisms/site-footer.twig" %}
4 changes: 2 additions & 2 deletions source/_patterns/05-pages/homepage.twig
Original file line number Diff line number Diff line change
@@ -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 %}
2 changes: 1 addition & 1 deletion templates/block--system-branding-block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#}

{% block content %}
{% include "@molecules/branding/branding.twig"
{% include "@molecules/branding.twig"
with {
"url": path('<front>')
}
Expand Down
2 changes: 1 addition & 1 deletion templates/node--teaser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
*/
#}

{% embed "@molecules/caption-block/caption-block.twig"
{% embed "@molecules/caption-block.twig"
with {
"title": label
}
Expand Down

0 comments on commit 6914f61

Please sign in to comment.