diff --git a/packages/patternengine-node-twig/.travis.yml b/packages/patternengine-node-twig/.travis.yml index 0adf4ab2c..25b0a05cd 100644 --- a/packages/patternengine-node-twig/.travis.yml +++ b/packages/patternengine-node-twig/.travis.yml @@ -1,8 +1,6 @@ language: node_js node_js: - - 4.1 - - 4.0 - 0.12 - 0.11 diff --git a/packages/patternengine-node-twig/CHANGELOG b/packages/patternengine-node-twig/CHANGELOG index 1c47bf53e..48cb65cea 100644 --- a/packages/patternengine-node-twig/CHANGELOG +++ b/packages/patternengine-node-twig/CHANGELOG @@ -1,5 +1,9 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. +PL-node-v0.13.1 +- FIX: Allow verbose partials for list items +- THX: Thanks @e2tha-e + PL-node-v0.13.0 - FIX: Cleanup an old file and an incorrect entry in the .gitignore file - CHG: Change order of pattern addition and ~variant pattern addition so they build naturally in the menu. diff --git a/packages/patternengine-node-twig/README.md b/packages/patternengine-node-twig/README.md index 336d031fb..f5f17cd93 100644 --- a/packages/patternengine-node-twig/README.md +++ b/packages/patternengine-node-twig/README.md @@ -10,6 +10,7 @@ This repository contains the vanilla builder logic, grunt and gulp configuration * Download the [latest release of patternlab-node](https://github.com/pattern-lab/patternlab-node/releases/latest) from Github * Via npm, run `npm install patternlab-node` (Note this will auto install the grunt version currently. see below) +* **NOTE** Node version 4.X is not officially supported yet, citing [a lot of Windows issues](https://github.com/nodejs/node-gyp/issues/629), including [mine](https://github.com/pattern-lab/patternlab-node/issues/162). Upgrade node at your own risk until otherwise stated. ### Choose Your Adventure! Now Vanilla, Grunt & Gulp diff --git a/packages/patternengine-node-twig/builder/list_item_hunter.js b/packages/patternengine-node-twig/builder/list_item_hunter.js index 50b3aa88a..bacd949fb 100644 --- a/packages/patternengine-node-twig/builder/list_item_hunter.js +++ b/packages/patternengine-node-twig/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/packages/patternengine-node-twig/test/list_item_hunter_tests.js b/packages/patternengine-node-twig/test/list_item_hunter_tests.js index 7f41cee88..6c6174e83 100644 --- a/packages/patternengine-node-twig/test/list_item_hunter_tests.js +++ b/packages/patternengine-node-twig/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