Skip to content

Commit 192b87f

Browse files
committed
patterspecific.listitems.json support
unit tests for list_item_hunter.js CHANGELOG and package for v0.11.0
1 parent 54369c1 commit 192b87f

13 files changed

+88
-67
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

33
PL-node-v0.11.0
44
- ADD: Ignore pattern directories that start with an underscore.
5+
- ADD: Support for lists with the listItems variable
56
- FIX: Resolved issue where pattern parameter data bled into global data object
67
- ADD: Support a fluid viewport
78

builder/lineage_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/list_item_hunter.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -31,8 +31,6 @@
3131

3232
//find the boundaries of the block
3333
var loopNumberString = liMatch.split('.')[1].split('}')[0].trim();
34-
35-
//find the boundaries of the block
3634
var end = liMatch.replace('#', '/');
3735
var patternBlock = pattern.template.substring(pattern.template.indexOf(liMatch) + liMatch.length, pattern.template.indexOf(end)).trim();
3836

@@ -43,23 +41,18 @@
4341
repeatedBlockTemplate.push(patternBlock);
4442
}
4543

44+
//check for a local listitems.json file
45+
var listData = JSON.parse(JSON.stringify(patternlab.listitems));
46+
listData = pattern_assembler.merge_data(listData, pattern.patternSpecificListJson);
47+
4648
//iterate over each copied block, rendering its contents along with pattenlab.listitems[i]
4749
for(var i = 0; i < repeatedBlockTemplate.length; i++){
4850

4951
var thisBlockTemplate = repeatedBlockTemplate[i];
5052
var thisBlockHTML = "";
5153

52-
//check for a local listitems.json file
53-
// var patternSpecificListJson = {};
54-
// try {
55-
// patternSpecificListJson = abspath.substr(0, abspath.lastIndexOf(".")) + "listitems.json";
56-
// currentPattern.jsonFileData = fs.readJSONSync(jsonFilename);
57-
// }
58-
// catch(e) {
59-
// }
60-
6154
//combine listItem data with pattern data with global data
62-
var itemData = patternlab.listitems['' + items.indexOf(loopNumberString)]; //this is a property
55+
var itemData = listData['' + items.indexOf(loopNumberString)]; //this is a property like "2"
6356
var globalData = JSON.parse(JSON.stringify(patternlab.data));
6457
var localData = JSON.parse(JSON.stringify(pattern.jsonFileData));
6558

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/parameter_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/pattern_assembler.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -81,12 +81,22 @@
8181

8282
//look for a json file for this template
8383
try {
84-
var jsonFilename = abspath.substr(0, abspath.lastIndexOf(".")) + ".json";
85-
currentPattern.jsonFileData = fs.readJSONSync(jsonFilename);
84+
var jsonFilename = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".json";
85+
currentPattern.jsonFileData = fs.readJSONSync(jsonFilename.substring(2));
86+
console.log('found pattern-specific data.json for ' + currentPattern.key);
8687
}
8788
catch(e) {
8889
}
8990

91+
//look for a listitems.json file for this template
92+
try {
93+
var listJsonFileName = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".listitems.json";
94+
currentPattern.patternSpecificListJson = fs.readJSONSync(listJsonFileName.substring(2));
95+
console.log('found pattern-specific listitems.json for ' + currentPattern.key);
96+
}
97+
catch(e) {
98+
}
99+
90100
//add the raw template to memory
91101
currentPattern.template = fs.readFileSync(abspath, 'utf8');
92102

builder/pattern_exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab_grunt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.10.1 - 2015
2+
* patternlab-node - v0.11.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

0 commit comments

Comments
 (0)