Skip to content

Commit 2c9527f

Browse files
committed
pattern parameters working with the new rendering algorithm. closes #88 pattern parameters
support for passing in inherited pattern partial data closes #127
1 parent bf66e78 commit 2c9527f

File tree

2 files changed

+18
-35
lines changed

2 files changed

+18
-35
lines changed

builder/parameter_hunter.js

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

@@ -37,7 +37,7 @@
3737

3838
//compile this partial immeadiately, essentially consuming it.
3939
//TODO: see how this affects lineage. perhaps add manually here.
40-
var partial = patternlab.partials[partialName];
40+
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
4141
var existingData = pattern.data || patternlab.data;
4242

4343
//merge paramData with any other data that exists.
@@ -49,22 +49,20 @@
4949

5050
//extend pattern data links into link for pattern link shortcuts to work. we do this locally and globally
5151
existingData.link = extend({}, patternlab.data.link);
52-
53-
var renderedPartial = pattern_assembler.renderPattern(partial, existingData, patternlab.partials);
52+
var renderedPartial = pattern_assembler.renderPattern(partialPattern.extendedTemplate, existingData, patternlab.partials);
5453

5554
//remove the parameter from the partial and replace it with the rendered partial + paramData
56-
pattern.template = pattern.template.replace(pMatch, renderedPartial);
55+
pattern.extendedTemplate = pattern.extendedTemplate.replace(pMatch, renderedPartial);
5756

58-
//TODO see if other data works
57+
//TODO: lineage is missing for this pattern
5958

6059
});
6160
}
62-
return matches !== null ? matches.length : 0;
6361
}
6462

6563
return {
6664
find_parameters: function(pattern, patternlab){
67-
return findparameters(pattern, patternlab);
65+
findparameters(pattern, patternlab);
6866
}
6967
};
7068

builder/pattern_assembler.js

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

@@ -103,7 +103,7 @@
103103
console.log('found partials for ' + currentPattern.key);
104104
}
105105
//determine if the template contains any pattern parameters. if so they must be immediately consumed
106-
var patternsConsumedWithParameters = parameter_hunter.find_parameters(currentPattern, patternlab);
106+
parameter_hunter.find_parameters(currentPattern, patternlab);
107107

108108
//do something with the regular old partials
109109
for(var i = 0; i < foundPatternPartials.length; i++){
@@ -123,21 +123,6 @@
123123
//find pattern lineage
124124
lineage_hunter.find_lineage(currentPattern, patternlab);
125125

126-
//add as a partial in case this is referenced later. convert to syntax needed by existing patterns
127-
// var sub = currentPattern.subdir.substring(currentPattern.subdir.indexOf('-') + 1);
128-
// var folderIndex = sub.indexOf(path.sep);
129-
// var cleanSub = sub.substring(0, folderIndex);
130-
//
131-
// //add any templates found to an object of partials, so downstream templates may use them too
132-
// //look for the full path on nested patterns, else expect it to be flat
133-
// var partialname = '';
134-
// if(cleanSub !== ''){
135-
// partialname = cleanSub + '-' + currentPattern.patternName;
136-
// } else{
137-
// partialname = currentPattern.patternGroup + '-' + currentPattern.patternName;
138-
// }
139-
// patternlab.partials[partialname] = currentPattern.template;
140-
141126
//look for a pseudo pattern by checking if there is a file containing same name, with ~ in it, ending in .json
142127
pseudopattern_hunter.find_pseudopatterns(currentPattern, patternlab);
143128

0 commit comments

Comments
 (0)