Skip to content

Commit 74314e8

Browse files
committed
Merge branch '685-listitem-data' into dev
2 parents fea8ae0 + 05f669b commit 74314e8

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

core/lib/patternlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ var patternlab_engine = function (config) {
504504
patternlab.data = {};
505505
}
506506
try {
507-
patternlab.listitems = dataLoader.loadDataFromFile(path.resolve(paths.source.data, 'listitems.{json,yml,yaml}'));
507+
patternlab.listitems = dataLoader.loadDataFromFile(path.resolve(paths.source.data, 'listitems'), fs);
508508
} catch (ex) {
509509
plutils.warning('WARNING: missing or malformed ' + paths.source.data + 'listitems file. Pattern Lab may not work without this file.');
510510
patternlab.listitems = {};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#listItems.three}}
2+
{{title}}
3+
{{/listItems.three}}

test/pattern_assembler_tests.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,40 @@ tap.test('processPatternRecursive - ensure deep-nesting works', function(test) {
456456
test.end();
457457
});
458458

459+
tap.test('processPatternRecursive - 685 ensure listitems data is used', function(test) {
460+
//arrange
461+
var pattern_assembler = new pa();
462+
var util = require('./util/test_utils.js');
463+
var testPatternsPath = path.resolve(__dirname, 'files', '_patterns');
464+
var pl = util.fakePatternLab(testPatternsPath);
465+
pl.data.title = "0";
466+
pl.listitems = {
467+
"1": {
468+
"title": "1"
469+
},
470+
"2": {
471+
"title": "2"
472+
},
473+
"3": {
474+
"title": "3"
475+
}
476+
};
477+
478+
pattern_assembler.combine_listItems(pl);
479+
480+
var listPatternPath = path.join('00-test', '685-list.mustache');
481+
var listPattern = pattern_assembler.process_pattern_iterative(listPatternPath, pl);
482+
483+
//act
484+
pattern_assembler.process_pattern_recursive(listPatternPath, pl);
485+
486+
//assert
487+
test.true(listPattern.extendedTemplate.indexOf(1) > -1);
488+
test.true(listPattern.extendedTemplate.indexOf(2) > -1);
489+
test.true(listPattern.extendedTemplate.indexOf(3) > -1);
490+
test.end();
491+
});
492+
459493
tap.test('setState - applies any patternState matching the pattern', function(test) {
460494
//arrange
461495
var pa = require('../core/lib/pattern_assembler');
@@ -803,4 +837,4 @@ tap.test('parses pattern extra frontmatter correctly when frontmatter present',
803837
//assert
804838
test.equals(testPattern.allMarkdown.joke, 'bad','extra key not added');
805839
test.end();
806-
});
840+
});

0 commit comments

Comments
 (0)