Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/list_item_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
for(var j = 0; j < foundPartials.length; j++){

//get the partial
var partialName = foundPartials[j].match(/([a-z-]+)/ig)[0];
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);

//replace its reference within the block with the extended template
Expand Down
67 changes: 67 additions & 0 deletions test/list_item_hunter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,73 @@
test.done();
},

'process_list_item_partials finds verbose partials and outputs repeated renders' : function(test){
var pattern1 = {
"template": "{{#listItems.one}}{{> 00-test/00-foo }}{{/listItems.one}}",
"extendedTemplate" : "{{#listItems.one}}{{> 00-test/00-foo }}{{/listItems.one}}",
"key": "test-patternName1",
"jsonFileData" : {}
};

var pattern2 = {
"template": "{{#listItems.two}}{{> 00-test/01-bar.mustache }}{{/listItems.two}}",
"extendedTemplate" : "{{#listItems.two}}{{> 00-test/01-bar.mustache }}{{/listItems.two}}",
"key": "test-patternName2",
"jsonFileData" : {}
};

var patternlab = {
"listitems": {
"1": [
{
"title": "Foo"
}
],
"2": [
{
"title": "Foo"
},
{
"title": "Bar"
}
]
},
"data": {
"link": {},
"partials": []
},
"config": {"debug": false},
"patterns": [
{
"template": "{{ title }}",
"extendedTemplate" : "{{ title }}",
"subdir": "00-test",
"fileName": "00-foo",
"jsonFileData" : {}
},
{
"template": "{{ title }}",
"extendedTemplate" : "{{ title }}",
"subdir": "00-test",
"fileName": "01-bar",
"jsonFileData" : {}
}
]
};

var list_item_hunter = new lih();

//act
list_item_hunter.process_list_item_partials(pattern1, patternlab);
list_item_hunter.process_list_item_partials(pattern2, patternlab);

//assert
test.equals(pattern1.extendedTemplate, "Foo" );
test.equals(pattern2.extendedTemplate, "FooBar" );

test.done();
},

'process_list_item_partials overwrites listItem property if that property is in local .listitem.json' : function(test){
//arrange
//setup current pattern from what we would have during execution
Expand Down