Skip to content

Commit 3bbee0d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/dev' into configurable-paths-galore
2 parents 9c65be0 + 0173a0a commit 3bbee0d

10 files changed

+363
-63
lines changed

CHANGELOG

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

3-
PL-node-v1.0.1
4-
- FIX: Fix issue where partials containing styleModifiers with integers were not found correctly under all circumstances
5-
- FIX: Fix 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.
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.
66
- THX: Thanks @theorise for reporting these issues.
77
- 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
814

915
PL-node-v1.0.0
1016
- FIX: Resolve issue with not hiding underscored patterns.

builder/lineage_hunter.js

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,41 @@
2323
if(matches !== null){
2424
matches.forEach(function(match, index, matches){
2525
//strip out the template cruft
26-
var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
26+
var foundPatternKey = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
2727

2828
// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
29-
if(foundPattern.indexOf('(') > 0){
30-
foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
29+
if(foundPatternKey.indexOf('(') > 0){
30+
foundPatternKey = foundPatternKey.substring(0, foundPatternKey.indexOf('('));
3131
}
3232

33-
//add if it doesnt exist
34-
if (pattern.lineageIndex.indexOf(foundPattern) === -1){
33+
//remove any potential stylemodifiers.
34+
foundPatternKey = foundPatternKey.split(':')[0];
3535

36-
pattern.lineageIndex.push(foundPattern);
36+
//get the ancestorPattern
37+
var ancestorPattern = pattern_assembler.get_pattern_by_key(foundPatternKey, patternlab);
3738

38-
patternlab.patterns.forEach(function(ancestorPattern, index, patterns){
39+
if (ancestorPattern && pattern.lineageIndex.indexOf(ancestorPattern.key) === -1){
3940

40-
//find the pattern in question
41-
var searchPattern = ancestorPattern.patternGroup + "-" + ancestorPattern.patternName;
41+
//add it since it didnt exist
42+
pattern.lineageIndex.push(ancestorPattern.key);
43+
//create the more complex patternLineage object too
44+
var l = {
45+
"lineagePattern": ancestorPattern.key,
46+
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
47+
};
48+
pattern.lineage.push(JSON.stringify(l));
4249

43-
if(searchPattern === foundPattern){
44-
//create the more complex patternLineage object too
45-
var l = {
46-
"lineagePattern": foundPattern,
47-
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
50+
//also, add the lineageR entry if it doesn't exist
51+
if (ancestorPattern.lineageRIndex.indexOf(pattern.key) === -1){
52+
ancestorPattern.lineageRIndex.push(pattern.key);
53+
54+
//create the more complex patternLineage object in reverse
55+
var lr = {
56+
"lineagePattern": pattern.key,
57+
"lineagePath": "../../patterns/" + pattern.patternLink
4858
};
49-
pattern.lineage.push(JSON.stringify(l));
50-
51-
//also, add the lineageR entry if it doesn't exist
52-
var patternLabel = pattern.patternGroup + "-" + pattern.patternName;
53-
if (ancestorPattern.lineageRIndex.indexOf(patternLabel) === -1){
54-
ancestorPattern.lineageRIndex.push(patternLabel);
55-
56-
//create the more complex patternLineage object in reverse
57-
var lr = {
58-
"lineagePattern": patternLabel,
59-
"lineagePath": "../../patterns/" + pattern.patternLink
60-
};
61-
ancestorPattern.lineageR.push(JSON.stringify(lr));
62-
}
59+
ancestorPattern.lineageR.push(JSON.stringify(lr));
6360
}
64-
65-
});
66-
6761
}
6862
});
6963
}

builder/list_item_hunter.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.0.1 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

@@ -72,13 +72,16 @@
7272
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
7373
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
7474

75+
//create a copy of the partial so as to not pollute it after the get_pattern_by_key call.
76+
var cleanPartialPattern = JSON.parse(JSON.stringify(partialPattern));
77+
7578
//if partial has style modifier data, replace the styleModifier value
76-
if(pattern.stylePartials && pattern.stylePartials.length > 0){
77-
style_modifier_hunter.consume_style_modifier(partialPattern, foundPartials[j], patternlab);
79+
if(foundPartials[j].indexOf(':') > -1){
80+
style_modifier_hunter.consume_style_modifier(cleanPartialPattern, foundPartials[j], patternlab);
7881
}
7982

8083
//replace its reference within the block with the extended template
81-
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], partialPattern.extendedTemplate);
84+
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], cleanPartialPattern.extendedTemplate);
8285
}
8386

8487
//render with data

builder/pattern_assembler.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.0.1 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

@@ -248,18 +248,35 @@
248248
}
249249

250250
function getpatternbykey(key, patternlab){
251+
252+
//look for exact key matches
253+
for(var i = 0; i < patternlab.patterns.length; i++){
254+
if(patternlab.patterns[i].key === key){
255+
return patternlab.patterns[i];
256+
}
257+
}
258+
259+
//else look by verbose syntax
251260
for(var i = 0; i < patternlab.patterns.length; i++){
252261
switch(key){
253-
case patternlab.patterns[i].key:
254262
case patternlab.patterns[i].subdir + '/' + patternlab.patterns[i].fileName:
255263
case patternlab.patterns[i].subdir + '/' + patternlab.patterns[i].fileName + '.mustache':
256264
return patternlab.patterns[i];
257265
}
258266
}
267+
268+
//return the fuzzy match if all else fails
269+
for(var i = 0; i < patternlab.patterns.length; i++){
270+
var keyParts = key.split('-'),
271+
keyType = keyParts[0],
272+
keyName = keyParts.slice(1).join('-');
273+
if(patternlab.patterns[i].key.split('-')[0] === keyType && patternlab.patterns[i].key.indexOf(keyName) > -1){
274+
return patternlab.patterns[i];
275+
}
276+
}
259277
throw 'Could not find pattern with key ' + key;
260278
}
261279

262-
263280
function mergeData(obj1, obj2){
264281
if(typeof obj2 === 'undefined'){
265282
obj2 = {};

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ gulp.task('connect', ['lab'], function(){
101101
baseDir: paths().public.root
102102
}
103103
});
104-
gulp.watch(path.resolve(paths().public.css, 'style.css'), ['cp:css']);
104+
gulp.watch(path.resolve(paths().source.css, '**/*.css'), ['cp:css']);
105105

106106
//suggested watches if you use scss
107107
// gulp.watch('./source/css/**/*.scss', ['sass:style']);
@@ -152,7 +152,7 @@ gulp.task('lab-pipe', ['lab'], function(cb){
152152

153153
gulp.task('default', ['lab']);
154154

155-
gulp.task('assets', ['cp:js', 'cp:img', 'cp:font', 'cp:data', /*'sass:style', 'sass:styleguide'*/]);
155+
gulp.task('assets', ['cp:js', 'cp:img', 'cp:font', 'cp:data', 'cp:css' /*'sass:style', 'sass:styleguide'*/]);
156156
gulp.task('prelab', ['clean', 'assets']);
157157
gulp.task('lab', ['prelab', 'patternlab'], function(cb){cb();});
158158
gulp.task('patterns', ['patternlab:only_patterns']);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="test_group">
2+
{{#listItems.two}}
3+
{{> test-styled-atom }}
4+
{{> test-styled-atom:test_1 }}
5+
{{> test-styled-atom}}
6+
{{/listItems.two}}
7+
</div>

0 commit comments

Comments
 (0)