diff --git a/builder/list_item_hunter.js b/builder/list_item_hunter.js index 50b3aa88a..bacd949fb 100644 --- a/builder/list_item_hunter.js +++ b/builder/list_item_hunter.js @@ -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 diff --git a/test/list_item_hunter_tests.js b/test/list_item_hunter_tests.js index 7f41cee88..6c6174e83 100644 --- a/test/list_item_hunter_tests.js +++ b/test/list_item_hunter_tests.js @@ -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