|
41 | 41 | } |
42 | 42 |
|
43 | 43 | function findListItems(pattern){ |
44 | | - var matches = pattern.template.match(/({{#( )?)(listItems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g); |
| 44 | + var matches = pattern.template.match(/({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g); |
45 | 45 | return matches; |
46 | 46 | } |
47 | 47 |
|
|
134 | 134 | //look for a listitems.json file for this template |
135 | 135 | try { |
136 | 136 | var listJsonFileName = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".listitems.json"; |
137 | | - currentPattern.patternSpecificListJson = fs.readJSONSync(listJsonFileName.substring(2)); |
| 137 | + currentPattern.listitems = fs.readJSONSync(listJsonFileName.substring(2)); |
| 138 | + buildListItems(currentPattern); |
138 | 139 | if(patternlab.config.debug){ |
139 | 140 | console.log('found pattern-specific listitems.json for ' + currentPattern.key); |
140 | 141 | } |
|
198 | 199 | console.log('found partials for ' + currentPattern.key); |
199 | 200 | } |
200 | 201 |
|
201 | | - //find any listItem partials |
| 202 | + //find any listItem blocks |
202 | 203 | list_item_hunter.process_list_item_partials(currentPattern, patternlab); |
203 | 204 |
|
204 | 205 | //determine if the template contains any pattern parameters. if so they must be immediately consumed |
|
234 | 235 |
|
235 | 236 | } |
236 | 237 |
|
| 238 | + } else{ |
| 239 | + //find any listItem blocks that within the pattern, even if there are no partials |
| 240 | + list_item_hunter.process_list_item_partials(currentPattern, patternlab); |
237 | 241 | } |
238 | 242 |
|
239 | 243 | //find pattern lineage |
|
293 | 297 | return obj2; |
294 | 298 | } |
295 | 299 |
|
296 | | - function buildListItems(patternlab){ |
| 300 | + function buildListItems(container){ |
297 | 301 | //combine all list items into one structure |
298 | 302 | var list = []; |
299 | | - for (var item in patternlab.listitems) { |
300 | | - if( patternlab.listitems.hasOwnProperty(item)) { |
301 | | - list.push(patternlab.listitems[item]); |
| 303 | + for (var item in container.listitems) { |
| 304 | + if( container.listitems.hasOwnProperty(item)) { |
| 305 | + list.push(container.listitems[item]); |
302 | 306 | } |
303 | 307 | } |
304 | | - patternlab.listItemArray = shuffle(list); |
| 308 | + container.listItemArray = shuffle(list); |
305 | 309 |
|
306 | | - for(var i = 1; i <= patternlab.listItemArray.length; i++){ |
| 310 | + for(var i = 1; i <= container.listItemArray.length; i++){ |
307 | 311 | var tempItems = []; |
308 | 312 | if( i === 1){ |
309 | | - tempItems.push(patternlab.listItemArray[0]); |
310 | | - patternlab.listitems['' + i ] = tempItems; |
| 313 | + tempItems.push(container.listItemArray[0]); |
| 314 | + container.listitems['' + i ] = tempItems; |
311 | 315 | } else{ |
312 | 316 | for(var c = 1; c <= i; c++){ |
313 | | - tempItems.push(patternlab.listItemArray[c - 1]); |
314 | | - patternlab.listitems['' + i ] = tempItems; |
| 317 | + tempItems.push(container.listItemArray[c - 1]); |
| 318 | + container.listitems['' + i ] = tempItems; |
315 | 319 | } |
316 | 320 | } |
317 | 321 | } |
|
0 commit comments