Skip to content

Commit c471eb0

Browse files
committed
fixed bug with pseudopatterns.
auto-indented all js files standardized my consoles a bit to just found things
1 parent 7486cff commit c471eb0

10 files changed

+180
-177
lines changed

builder/lineage_hunter.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";

builder/media_hunter.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";
1313

1414
var diveSync = require('diveSync'),
15-
path = require('path'),
16-
fs = require('fs-extra');
15+
path = require('path'),
16+
fs = require('fs-extra');
1717

1818
var media_hunter = function(){
1919

builder/object_factory.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";

builder/parameter_hunter.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";
1313

1414
var parameter_hunter = function(){
1515

1616
var extend = require('util')._extend,
17-
pa = require('./pattern_assembler'),
18-
mustache = require('mustache'),
19-
pattern_assembler = new pa();
17+
pa = require('./pattern_assembler'),
18+
mustache = require('mustache'),
19+
pattern_assembler = new pa();
2020

2121
function findparameters(pattern, patternlab){
2222

@@ -27,6 +27,10 @@
2727
//find the partial's name
2828
var partialName = pMatch.match(/([a-z-]+)/ig)[0]
2929

30+
if(patternlab.config.debug){
31+
console.log('found patternParameters for ' + partialName);
32+
}
33+
3034
//strip out the additional data and eval
3135
var leftParen = pMatch.indexOf('(');
3236
var rightParen = pMatch.indexOf(')');
@@ -42,9 +46,9 @@
4246

4347
//merge paramData with any other data that exists.
4448
for (var prop in paramData) {
45-
if (existingData.hasOwnProperty(prop)) {
46-
existingData[prop] = paramData[prop];
47-
}
49+
if (existingData.hasOwnProperty(prop)) {
50+
existingData[prop] = paramData[prop];
51+
}
4852
}
4953

5054
//extend pattern data links into link for pattern link shortcuts to work. we do this locally and globally

builder/pattern_assembler.js

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";
@@ -45,8 +45,8 @@
4545

4646
function processPatternFile(file, patternlab){
4747
var fs = require('fs-extra'),
48-
of = require('./object_factory'),
49-
path = require('path');
48+
of = require('./object_factory'),
49+
path = require('path');
5050

5151
//extract some information
5252
var abspath = file.substring(2);
@@ -82,15 +82,15 @@
8282
function processPattern(currentPattern, patternlab, additionalData){
8383

8484
var fs = require('fs-extra'),
85-
mustache = require('mustache'),
86-
lh = require('./lineage_hunter'),
87-
ph = require('./parameter_hunter'),
88-
pph = require('./pseudopattern_hunter'),
89-
path = require('path');
85+
mustache = require('mustache'),
86+
lh = require('./lineage_hunter'),
87+
ph = require('./parameter_hunter'),
88+
pph = require('./pseudopattern_hunter'),
89+
path = require('path');
9090

9191
var parameter_hunter = new ph(),
92-
lineage_hunter = new lh(),
93-
pseudopattern_hunter = new pph();
92+
lineage_hunter = new lh(),
93+
pseudopattern_hunter = new pph();
9494

9595
currentPattern.extendedTemplate = currentPattern.template;
9696

@@ -108,16 +108,10 @@
108108
//do something with the regular old partials
109109
for(var i = 0; i < foundPatternPartials.length; i++){
110110
var partialKey = foundPatternPartials[i].replace(/{{>([ ])?([A-Za-z0-9-]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ])?}}/g, '$2');
111-
console.log('key for partial is ' + partialKey);
112111
var partialPattern = getpatternbykey(partialKey, patternlab);
113112
currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace(foundPatternPartials[i], partialPattern.extendedTemplate);
114113
}
115114

116-
} else{
117-
//we found no partials, so we are ready to render
118-
if(patternlab.config.debug){
119-
console.log('no partial found in pattern ' + currentPattern.key);
120-
}
121115
}
122116

123117
//find pattern lineage
@@ -139,28 +133,28 @@
139133
throw 'Could not find pattern with key ' + key;
140134
}
141135

142-
/*
143-
* Recursively merge properties of two objects
144-
* http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically
145-
*/
146-
function mergeData(obj1, obj2) {
147-
for (var p in obj2) {
148-
try {
149-
// Property in destination object set; update its value.
150-
if ( obj2[p].constructor == Object ) {
151-
obj1[p] = merge_data(obj1[p], obj2[p]);
152-
153-
} else {
136+
/*
137+
* Recursively merge properties of two objects
138+
* http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically
139+
*/
140+
var self = this;
141+
function mergeData(obj1, obj2) {
142+
for (var p in obj2) {
143+
try {
144+
// Property in destination object set; update its value.
145+
if ( obj2[p].constructor == Object ) {
146+
obj1[p] = self.merge_data(obj1[p], obj2[p]);
147+
148+
} else {
149+
obj1[p] = obj2[p];
150+
}
151+
} catch(e) {
152+
// Property in destination object not set; create it and set its value.
154153
obj1[p] = obj2[p];
155-
156154
}
157-
} catch(e) {
158-
// Property in destination object not set; create it and set its value.
159-
obj1[p] = obj2[p];
160155
}
156+
return obj1;
161157
}
162-
return obj1;
163-
}
164158

165159
return {
166160
find_pattern_partials: function(pattern){

builder/pattern_exporter.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
(function () {
1212
"use strict";
1313

1414
var fs = require('fs-extra'),
15-
path = require('path');
15+
path = require('path');
1616

1717
var pattern_exporter = function(){
1818

@@ -31,7 +31,7 @@
3131
}
3232
}
3333

34-
34+
3535

3636
}
3737

@@ -45,4 +45,4 @@
4545

4646
module.exports = pattern_exporter;
4747

48-
}());
48+
}());

builder/patternlab.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
2-
* patternlab-node - v0.10.0 - 2015
3-
*
4-
* 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.
8-
*
9-
*/
1+
/*
2+
* patternlab-node - v0.10.0 - 2015
3+
*
4+
* 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.
8+
*
9+
*/
1010

1111
var patternlab_engine = function () {
1212
'use strict';
@@ -64,8 +64,8 @@ var patternlab_engine = function () {
6464
patternlab.data.link = {};
6565

6666
var pattern_assembler = new pa(),
67-
entity_encoder = new he(),
68-
pattern_exporter = new pe();
67+
entity_encoder = new he(),
68+
pattern_exporter = new pe();
6969

7070
diveSync('./source/_patterns', function(err, file){
7171
//log any errors
@@ -77,15 +77,14 @@ var patternlab_engine = function () {
7777
pattern_assembler.process_pattern_file(file, patternlab);
7878

7979
});
80-
8180
//render all patterns last, so lineageR works
8281
patternlab.patterns.forEach(function(pattern, index, patterns){
83-
8482
//render the pattern, but first consolidate any data we may have
85-
var allData = patternlab.data;
83+
var allData = JSON.parse(JSON.stringify(patternlab.data));
8684
allData = pattern_assembler.merge_data(allData, pattern.jsonFileData);
8785
allData = pattern_assembler.merge_data(allData, pattern.data);
88-
pattern.patternPartial = pattern_assembler.renderPattern(pattern.extendedTemplate, patternlab.data);
86+
87+
pattern.patternPartial = pattern_assembler.renderPattern(pattern.extendedTemplate, allData);
8988

9089
//add footer info before writing
9190
var patternFooter = pattern_assembler.renderPattern(patternlab.footer, pattern);
@@ -107,7 +106,7 @@ var patternlab_engine = function () {
107106

108107
function buildFrontEnd(){
109108
var pattern_assembler = new pa(),
110-
media_hunter = new mh();
109+
media_hunter = new mh();
111110
patternlab.buckets = [];
112111
patternlab.bucketIndex = [];
113112
patternlab.patternPaths = {};
@@ -118,12 +117,12 @@ var patternlab_engine = function () {
118117

119118
//build the styleguide
120119
var styleguideTemplate = fs.readFileSync('./source/_patternlab-files/styleguide.mustache', 'utf8'),
121-
styleguideHtml = pattern_assembler.renderPattern(styleguideTemplate, {partials: patternlab.patterns});
120+
styleguideHtml = pattern_assembler.renderPattern(styleguideTemplate, {partials: patternlab.patterns});
122121
fs.outputFileSync('./public/styleguide/html/styleguide.html', styleguideHtml);
123122

124123
//build the viewall pages
125124
var prevSubdir = '',
126-
i;
125+
i;
127126

128127
for (i = 0; i < patternlab.patterns.length; i++) {
129128
var pattern = patternlab.patterns[i];

0 commit comments

Comments
 (0)