|
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 | +*/ |
10 | 10 |
|
11 | 11 | (function () { |
12 | 12 | "use strict"; |
|
45 | 45 |
|
46 | 46 | function processPatternFile(file, patternlab){ |
47 | 47 | var fs = require('fs-extra'), |
48 | | - of = require('./object_factory'), |
49 | | - path = require('path'); |
| 48 | + of = require('./object_factory'), |
| 49 | + path = require('path'); |
50 | 50 |
|
51 | 51 | //extract some information |
52 | 52 | var abspath = file.substring(2); |
|
82 | 82 | function processPattern(currentPattern, patternlab, additionalData){ |
83 | 83 |
|
84 | 84 | 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'); |
90 | 90 |
|
91 | 91 | 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(); |
94 | 94 |
|
95 | 95 | currentPattern.extendedTemplate = currentPattern.template; |
96 | 96 |
|
|
108 | 108 | //do something with the regular old partials |
109 | 109 | for(var i = 0; i < foundPatternPartials.length; i++){ |
110 | 110 | var partialKey = foundPatternPartials[i].replace(/{{>([ ])?([A-Za-z0-9-]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ])?}}/g, '$2'); |
111 | | - console.log('key for partial is ' + partialKey); |
112 | 111 | var partialPattern = getpatternbykey(partialKey, patternlab); |
113 | 112 | currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace(foundPatternPartials[i], partialPattern.extendedTemplate); |
114 | 113 | } |
115 | 114 |
|
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 | | - } |
121 | 115 | } |
122 | 116 |
|
123 | 117 | //find pattern lineage |
|
139 | 133 | throw 'Could not find pattern with key ' + key; |
140 | 134 | } |
141 | 135 |
|
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. |
154 | 153 | obj1[p] = obj2[p]; |
155 | | - |
156 | 154 | } |
157 | | - } catch(e) { |
158 | | - // Property in destination object not set; create it and set its value. |
159 | | - obj1[p] = obj2[p]; |
160 | 155 | } |
| 156 | + return obj1; |
161 | 157 | } |
162 | | - return obj1; |
163 | | - } |
164 | 158 |
|
165 | 159 | return { |
166 | 160 | find_pattern_partials: function(pattern){ |
|
0 commit comments