Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit dc43f4a

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #233 from geoffp/pattern-engines
Pattern engines ongoing work, round 5 (I think)
2 parents 4f52169 + 61ef4d7 commit dc43f4a

34 files changed

+852
-370
lines changed

.eslintrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
"allow-null"
2323
],
2424
"global-strict": [
25-
2,
25+
0,
2626
"never"
2727
],
2828
"guard-for-in": 2,
29-
"key-spacing": 1,
29+
"key-spacing": [
30+
0
31+
],
3032
"new-cap": 0,
3133
"no-bitwise": 2,
3234
"no-caller": 2,
@@ -42,6 +44,7 @@
4244
"no-irregular-whitespace": 1,
4345
"no-iterator": 2,
4446
"no-loop-func": 2,
47+
"no-mixed-requires": 0,
4548
"no-multi-str": 2,
4649
"no-multi-spaces": 0,
4750
"no-new": 2,
@@ -61,7 +64,7 @@
6164
0,
6265
"never"
6366
],
64-
"strict": 2,
67+
"strict": 0,
6568
"valid-typeof": 2,
6669
"wrap-iife": [
6770
2,

CHANGELOG

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

3+
PL-node-v1.1.0
4+
- FIX: Fixed issue where partials containing styleModifiers with integers were not found correctly under all circumstances
5+
- FIX: Fixed issue where excluded patterns were still rendered on the Pattern Lab site. Now they do not directly get rendered via the menu, view all links, or the styleguide, but are accessible for inclusion as pattern partials, and can be accessed via lineage.
6+
- THX: Thanks @theorise for reporting these issues.
7+
- THX: Thanks @dmolsen for input on desired behavior.
8+
- FIX: Fixed issue where style modifier partials within list item blocks where not uniquely being applied. this seems like a regression. added a unit test with fix
9+
- ADD: Added fuzzy pattern matching support based on patternType-substring(patternName) to align with PL PHP
10+
- FIX: Fixed issue with gulpfile not copying style.css and watching the wrong directory
11+
- THX: Thanks @robinsonaaron for the issue and pull request!
12+
- FIX: Prefer exact pattern key match over fuzzy matches inside getpatternbykey()
13+
- THX: Thanks @EvanLovely for the suggestion
14+
- FIX: Fix issue where absolute paths in the config path object would not resolve
15+
- THX: Thanks to @geoffp and @EvanLovely for reporting, fixing and testing the issue in the dev branch.
16+
- FIX: Typo in gulp instructions in README.
17+
- THX: Thanks @simonknittel for the watchful eyes
18+
319
PL-node-v1.0.0
420
- FIX: Resolve issue with not hiding underscored patterns.
521
- THX: Thanks @ivancamilov for reporting this regression.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ To run patternlab-node using gulp, you need to swap out the default grunt config
4444
3. Run `npm install` from the command line
4545
4. Run `gulp` or `gulp serve` from the command line
4646

47-
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to see have BrowserSync spin up and serve the files to you.
47+
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `gulp serve` to have BrowserSync spin up and serve the files to you.
4848

4949
### There and Back Again, or Switching Between Grunt and Gulp
5050

builder/lineage_hunter.js

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v1.0.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -17,54 +17,36 @@
1717

1818
var pa = require('./pattern_assembler');
1919
var pattern_assembler = new pa();
20-
var config = require('../config.json');
2120

2221
//find the {{> template-name }} within patterns
2322
var matches = pattern.findPartials();
2423
if(matches !== null){
2524
matches.forEach(function(match, index, matches){
26-
//strip out the template cruft
27-
var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
28-
29-
// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
30-
if(foundPattern.indexOf('(') > 0){
31-
foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
32-
}
33-
34-
//add if it doesnt exist
35-
if (pattern.lineageIndex.indexOf(foundPattern) === -1){
36-
37-
pattern.lineageIndex.push(foundPattern);
38-
39-
patternlab.patterns.forEach(function(ancestorPattern, index, patterns){
40-
41-
//find the pattern in question
42-
var searchPattern = ancestorPattern.patternGroup + "-" + ancestorPattern.patternName;
43-
44-
if(searchPattern === foundPattern){
45-
//create the more complex patternLineage object too
46-
var l = {
47-
"lineagePattern": foundPattern,
48-
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
25+
//get the ancestorPattern
26+
var ancestorPattern = pattern_assembler.get_pattern_by_key(pattern.findPartialKey(match), patternlab);
27+
28+
if (ancestorPattern && pattern.lineageIndex.indexOf(ancestorPattern.key) === -1){
29+
//add it since it didnt exist
30+
pattern.lineageIndex.push(ancestorPattern.key);
31+
32+
//create the more complex patternLineage object too
33+
var l = {
34+
"lineagePattern": ancestorPattern.key,
35+
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
36+
};
37+
pattern.lineage.push(JSON.stringify(l));
38+
39+
//also, add the lineageR entry if it doesn't exist
40+
if (ancestorPattern.lineageRIndex.indexOf(pattern.key) === -1){
41+
ancestorPattern.lineageRIndex.push(pattern.key);
42+
43+
//create the more complex patternLineage object in reverse
44+
var lr = {
45+
"lineagePattern": pattern.key,
46+
"lineagePath": "../../patterns/" + pattern.patternLink
4947
};
50-
pattern.lineage.push(JSON.stringify(l));
51-
52-
//also, add the lineageR entry if it doesn't exist
53-
var patternLabel = pattern.patternGroup + "-" + pattern.patternName;
54-
if (ancestorPattern.lineageRIndex.indexOf(patternLabel) === -1){
55-
ancestorPattern.lineageRIndex.push(patternLabel);
56-
57-
//create the more complex patternLineage object in reverse
58-
var lr = {
59-
"lineagePattern": patternLabel,
60-
"lineagePath": "../../patterns/" + pattern.patternLink
61-
};
62-
ancestorPattern.lineageR.push(JSON.stringify(lr));
63-
}
48+
ancestorPattern.lineageR.push(JSON.stringify(lr));
6449
}
65-
66-
});
67-
6850
}
6951
});
7052
}

builder/list_item_hunter.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v1.0.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -17,7 +17,6 @@
1717
pa = require('./pattern_assembler'),
1818
smh = require('./style_modifier_hunter'),
1919
plutils = require('./utilities'),
20-
config = require('../config.json'),
2120
of = require('./object_factory');
2221

2322
var pattern_assembler = new pa(),
@@ -31,7 +30,7 @@
3130
if(matches !== null){
3231
matches.forEach(function(liMatch, index, matches){
3332

34-
if(config.debug){
33+
if(patternlab.config.debug){
3534
console.log('found listItem of size ' + liMatch + ' inside ' + pattern.key);
3635
}
3736

@@ -43,7 +42,7 @@
4342
var repeatedBlockTemplate = [];
4443
var repeatedBlockHtml = '';
4544
for(var i = 0; i < items.indexOf(loopNumberString); i++){
46-
if (config.debug) {
45+
if (patternlab.config.debug) {
4746
console.log('list item(s) in pattern', pattern.patternName, 'adding', patternBlock, 'to repeatedBlockTemplate');
4847
}
4948
repeatedBlockTemplate.push(patternBlock);
@@ -79,13 +78,16 @@
7978
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
8079
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
8180

81+
//create a copy of the partial so as to not pollute it after the get_pattern_by_key call.
82+
var cleanPartialPattern = JSON.parse(JSON.stringify(partialPattern));
83+
8284
//if partial has style modifier data, replace the styleModifier value
83-
if(pattern.stylePartials && pattern.stylePartials.length > 0){
84-
style_modifier_hunter.consume_style_modifier(partialPattern, foundPartials[j], patternlab);
85+
if(foundPartials[j].indexOf(':') > -1){
86+
style_modifier_hunter.consume_style_modifier(cleanPartialPattern, foundPartials[j], patternlab);
8587
}
8688

8789
//replace its reference within the block with the extended template
88-
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], partialPattern.extendedTemplate);
90+
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], cleanPartialPattern.extendedTemplate);
8991
}
9092

9193
//render with data

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.0.0 - 2015
2+
* patternlab-node - v1.0.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v1.0.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -14,7 +14,6 @@
1414
var patternEngines = require('./pattern_engines/pattern_engines');
1515
var path = require('path');
1616
var fs = require('fs-extra');
17-
var config = fs.readJSONSync('./config.json');
1817
var extend = require('util')._extend;
1918

2019
// oPattern properties
@@ -52,10 +51,7 @@
5251
// render method on oPatterns; this acts as a proxy for the PatternEngine's
5352
// render function
5453
render: function (data, partials) {
55-
if (config.debug && this.isPseudoPattern) {
56-
console.log('===', this.name + ' IS A PSEUDO-PATTERN ===');
57-
}
58-
return this.engine.renderPattern(this.extendedTemplate, data, partials);
54+
return this.engine.renderPattern(this.extendedTemplate, data || this.jsonFileData, partials);
5955
},
6056

6157
registerPartial: function () {
@@ -82,8 +78,8 @@
8278
return this.engine.findListItems(this);
8379
},
8480

85-
getPartialKey: function (partialString) {
86-
return this.engine.getPartialKey(this, partialString);
81+
findPartialKey: function (partialString) {
82+
return this.engine.findPartialKey(partialString);
8783
}
8884
};
8985

builder/parameter_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v1.0.0 - 2015
2+
* patternlab-node - v1.0.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

0 commit comments

Comments
 (0)