Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit bf68c71

Browse files
committed
fix lint
1 parent 4dd2fb9 commit bf68c71

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

docs/features/pattern-lab.md

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ From your Drupal Twig templates in `templates/` you can `{% include %}`, `{% ext
2222

2323
For a demonstration in a sample codebase of how exactly to integrate templates, see the [`drupal-lab`](https://github.com/phase2/drupal-lab) repo; in particular note how both a [node teaser template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/templates/content/node--article--teaser.html.twig) and a [views field template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/templates/views/views-view-fields--newspage--page.html.twig) in the Drupal `templates/` folder can embed the [card template](https://github.com/phase2/drupal-lab/blob/master/web/themes/dashing/pattern-lab/source/_patterns/02-molecules/cards/card.twig) from Pattern Lab while formatting the data.
2424

25+
### A word on twig template inheritance
26+
27+
- `include`: Dump the contents of that template into this one.
28+
- `extends`: Take the old template and allow me to override blocks defined in the other template - I don't get to redefine everything and I don't get to define new blocks - I just get to suppress the old block definition and redefine it (and then I can dump the parent template's block definition into my definition if I use` {{ parent() }}` – kinda like doing an include just of that one block from the parent template's definition into your child template definition
29+
- `embed`: Include but then override blocks from that include (super useful for layouts).
30+
2531

2632
## Additional features
2733

lib/pattern-lab--php-twig.js

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
23
const core = require('./core');
34
const path = require('path');
45
const yaml = require('js-yaml');
@@ -9,9 +10,7 @@ const browserSync = require('browser-sync');
910
const glob = require('glob');
1011

1112
module.exports = (gulp, config, tasks) => {
12-
let plConfig = yaml.safeLoad(
13-
fs.readFileSync(config.patternLab.configFile, 'utf8')
14-
);
13+
let plConfig = yaml.safeLoad(fs.readFileSync(config.patternLab.configFile, 'utf8'));
1514
const plRoot = path.join(config.patternLab.configFile, '../..');
1615
const plSource = path.join(plRoot, plConfig.sourceDir);
1716
const plPublic = path.join(plRoot, plConfig.publicDir);
@@ -62,7 +61,7 @@ module.exports = (gulp, config, tasks) => {
6261
relative: false,
6362
addRootSlash: false,
6463
addSuffix: '?cacheBuster={{ cacheBuster }}',
65-
addPrefix: path.join('../..', path.relative(plPublic, process.cwd())),
64+
addPrefix: path.join('../..', path.relative(plPublic, process.cwd()))
6665
}))
6766
.pipe(gulp.dest(plMeta))
6867
.on('end', done);
@@ -83,7 +82,7 @@ module.exports = (gulp, config, tasks) => {
8382
return {
8483
name: x[0].trim(), // i.e. $color-gray
8584
value: y[0].replace(/!.*/, '').trim(), // i.e. hsl(0, 0%, 50%) after removing `!default`
86-
comment: y[1].replace('//', '').trim(), // any inline comment coming after, i.e. `// main gray color`
85+
comment: y[1].replace('//', '').trim() // any inline comment coming after, i.e. `// main gray color`
8786
};
8887
});
8988

@@ -94,8 +93,8 @@ module.exports = (gulp, config, tasks) => {
9493
fs.writeFileSync(pair.dest, JSON.stringify({
9594
items: varsAndValues,
9695
meta: {
97-
description: `To add to these items, use Sass variables that start with <code>${pair.lineStartsWith}</code> in <code>${pair.src}</code>`,
98-
},
96+
description: `To add to these items, use Sass variables that start with <code>${pair.lineStartsWith}</code> in <code>${pair.src}</code>`
97+
}
9998
}, null, ' '));
10099
});
101100
done();
@@ -124,17 +123,15 @@ module.exports = (gulp, config, tasks) => {
124123
return results;
125124
});
126125
twigNamespaceConfig[namespaceSet.namespace] = {
127-
paths: core.uniqueArray(core.flattenArray(pathArray)),
126+
paths: core.uniqueArray(core.flattenArray(pathArray))
128127
};
129128
});
130129
return twigNamespaceConfig;
131130
}
132131

133132
function addTwigNamespaceConfigToDrupal(done) {
134133
const twigNamespaceConfig = getTwigNamespaceConfig(path.dirname(config.drupal.themeFile));
135-
const drupalThemeFile = yaml.safeLoad(
136-
fs.readFileSync(config.drupal.themeFile, 'utf8')
137-
);
134+
const drupalThemeFile = yaml.safeLoad(fs.readFileSync(config.drupal.themeFile, 'utf8'));
138135

139136
if (!drupalThemeFile['component-libraries']) {
140137
drupalThemeFile['component-libraries'] = {};
@@ -148,18 +145,16 @@ module.exports = (gulp, config, tasks) => {
148145

149146
function addTwigNamespaceConfigToPl(done) {
150147
const twigNamespaceConfig = getTwigNamespaceConfig(plRoot);
151-
plConfig = yaml.safeLoad(
152-
fs.readFileSync(config.patternLab.configFile, 'utf8')
153-
);
148+
plConfig = yaml.safeLoad(fs.readFileSync(config.patternLab.configFile, 'utf8'));
154149
if (!plConfig.plugins) {
155150
Object.assign(plConfig, {
156151
plugins: {
157-
twigNamespaces: { enabled: true, namespaces: {} },
158-
},
152+
twigNamespaces: { enabled: true, namespaces: {} }
153+
}
159154
});
160155
} else if (!plConfig.plugins.twigNamespaces) {
161156
Object.assign(plConfig.plugins, {
162-
twigNamespaces: { enabled: true, namespaces: {} },
157+
twigNamespaces: { enabled: true, namespaces: {} }
163158
});
164159
} else if (!plConfig.plugins.twigNamespaces.namespaces) {
165160
plConfig.plugins.twigNamespaces.namespaces = {};

0 commit comments

Comments
 (0)