From 1f456d2d6e5602919ac75e660fcf5a2ab71f943a Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Wed, 3 May 2017 04:12:29 -0500 Subject: [PATCH 1/4] added backers to README --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8bb404298..942921085 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,15 @@ This repository contains the core functionality for Pattern Lab Node. Pattern La [Online Demo of Pattern Lab Output](http://demo.patternlab.io/) +## Support for Pattern Lab Node + +Pattern Lab Node wouldn't be what it is today without the support of the community. It will always be free and open source. Continued development is made possible in part from the support of [these wonderful project supporters](https://github.com/pattern-lab/patternlab-node/wiki/Thanks). If you want to learn more about supporting the project, visit the [Pattern Lab Node Patreon page](https://www.patreon.com/patternlab). + +**:100: Thanks for support from the following:** + +* **[Brad Frost](http://bradfrost.com/)** +* Marcos Peebles + ## Installation Pattern Lab Node Core is designed to be consumed, and by default is included as a dependency within two example [Node Editions](https://github.com/pattern-lab?utf8=%E2%9C%93&query=edition-node). @@ -84,15 +93,6 @@ There is also a dedicated Pattern Lab channel on the [design system slack](desig Ask or answer Pattern Lab questions on Stack Overflow: http://stackoverflow.com/questions/tagged/patternlab.io -## Support Pattern Lab Node - -Pattern Lab Node is on [Patreon account](https://www.patreon.com/patternlab) to allow users and organizations to directly support continued work on the Pattern Lab Node project. - -I (Brian talking) need help and support to make Pattern Lab Node a sustained success. I devote a lot of free time and would-be sleep to make the project what it is, but nothing compares to hearing back from users. It means the world to me when people find value in Pattern Lab Node. I am ridiculously humbled to hear and see what you all build with it. - -If you find yourself here and balk and the idea of supporting open source software monetarily - I understand. Carry on, but please do share what you build - we all learn more together. -- [Pattern Lab on Patreon](https://www.patreon.com/patternlab) - ## License [MIT](https://github.com/pattern-lab/patternlab-node/blob/master/LICENSE) From 0496f0d050ea219c02a85bf3db3a50d12c4f26de Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Fri, 19 May 2017 01:16:04 -0500 Subject: [PATCH 2/4] failing unit test demonstrating behavior in #539 and https://github.com/pattern-lab/starterkit-mustache-acidtest/issues/1 --- core/lib/parameter_hunter.js | 3 + test/files/_patterns/00-test/539-a.mustache | 4 ++ test/files/_patterns/00-test/539-b.mustache | 5 ++ test/files/_patterns/00-test/539-c.mustache | 2 + test/parameter_hunter_tests.js | 64 ++++++++++++++++++++- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 test/files/_patterns/00-test/539-a.mustache create mode 100644 test/files/_patterns/00-test/539-b.mustache create mode 100644 test/files/_patterns/00-test/539-c.mustache diff --git a/core/lib/parameter_hunter.js b/core/lib/parameter_hunter.js index 44f33adeb..c52667cc5 100644 --- a/core/lib/parameter_hunter.js +++ b/core/lib/parameter_hunter.js @@ -271,6 +271,9 @@ var parameter_hunter = function () { var allData = plutils.mergeData(globalData, localData); allData = plutils.mergeData(allData, paramData); + //if the partial has pattern parameters itself, we need to handle those + // findparameters(partialPattern, patternlab); + //if partial has style modifier data, replace the styleModifier value if (pattern.stylePartials && pattern.stylePartials.length > 0) { style_modifier_hunter.consume_style_modifier(partialPattern, pMatch, patternlab); diff --git a/test/files/_patterns/00-test/539-a.mustache b/test/files/_patterns/00-test/539-a.mustache new file mode 100644 index 000000000..ba154f442 --- /dev/null +++ b/test/files/_patterns/00-test/539-a.mustache @@ -0,0 +1,4 @@ +a +{{ #a }} +a! +{{ /a }} diff --git a/test/files/_patterns/00-test/539-b.mustache b/test/files/_patterns/00-test/539-b.mustache new file mode 100644 index 000000000..70997abb3 --- /dev/null +++ b/test/files/_patterns/00-test/539-b.mustache @@ -0,0 +1,5 @@ +b +{{ #b }} +b! +{{ /b }} +{{> test-a(a: true) }} diff --git a/test/files/_patterns/00-test/539-c.mustache b/test/files/_patterns/00-test/539-c.mustache new file mode 100644 index 000000000..6098102c8 --- /dev/null +++ b/test/files/_patterns/00-test/539-c.mustache @@ -0,0 +1,2 @@ +c +{{> test-b(b: true) }} diff --git a/test/parameter_hunter_tests.js b/test/parameter_hunter_tests.js index 092f44428..a94e42e75 100644 --- a/test/parameter_hunter_tests.js +++ b/test/parameter_hunter_tests.js @@ -1,9 +1,16 @@ "use strict"; var tap = require('tap'); +var pa = require('../core/lib/pattern_assembler'); +var Pattern = require('../core/lib/object_factory').Pattern; +var CompileState = require('../core/lib/object_factory').CompileState; +var PatternGraph = require('../core/lib/pattern_graph').PatternGraph; + +var fs = require('fs-extra'); var ph = require('../core/lib/parameter_hunter'); + //setup current pattern from what we would have during execution function currentPatternClosure() { return { @@ -48,9 +55,11 @@ function patternlabClosure() { debug: false }, data: { - description: 'Not a quote from a smart man' + description: 'Not a quote from a smart man', + link: {} }, - partials: {} + partials: {}, + graph: PatternGraph.empty() } }; @@ -65,6 +74,57 @@ tap.test('parameter hunter finds and extends templates', function(test) { test.end(); }); +tap.test('parameter hunter finds partials with their own parameters and renders them too', function(test) { + //arrange + + var pattern_assembler = new pa(); + var patterns_dir = './test/files/_patterns/'; + + var pl = patternlabClosure(); + + + var aPattern = new Pattern('00-test/539-a.mustache'); + aPattern.template = fs.readFileSync(patterns_dir + '00-test/539-a.mustache', 'utf8'); + aPattern.extendedTemplate = aPattern.template; + aPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(aPattern); + aPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(aPattern); + + var bPattern = new Pattern('00-test/539-b.mustache'); + bPattern.template = fs.readFileSync(patterns_dir + '00-test/539-b.mustache', 'utf8'); + bPattern.extendedTemplate = bPattern.template; + bPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(bPattern); + bPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(bPattern); + + var cPattern = new Pattern('00-test/539-c.mustache'); + cPattern.template = fs.readFileSync(patterns_dir + '00-test/539-c.mustache', 'utf8'); + cPattern.extendedTemplate = cPattern.template; + cPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(cPattern); + cPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(cPattern); + + pattern_assembler.addPattern(aPattern, pl); + pattern_assembler.addPattern(bPattern, pl); + pattern_assembler.addPattern(cPattern, pl); + + var currentPattern = cPattern; + var parameter_hunter = new ph(); + + //act + parameter_hunter.find_parameters(currentPattern, pl); + + //assert + test.equals(currentPattern.extendedTemplate, + `c +b +b! +a +a! + + +`); + + test.end(); +}); + tap.test('parameter hunter finds and extends templates with mixed parameter and global data', function(test) { var currentPattern = currentPatternClosure(); var patternlab = patternlabClosure(); From 5998c9c08e6df4e3cc0d20c61d7ead2bb19f54c0 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Fri, 19 May 2017 01:19:25 -0500 Subject: [PATCH 3/4] apply fix --- core/lib/parameter_hunter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/parameter_hunter.js b/core/lib/parameter_hunter.js index c52667cc5..b9c64f06f 100644 --- a/core/lib/parameter_hunter.js +++ b/core/lib/parameter_hunter.js @@ -272,7 +272,7 @@ var parameter_hunter = function () { allData = plutils.mergeData(allData, paramData); //if the partial has pattern parameters itself, we need to handle those - // findparameters(partialPattern, patternlab); + findparameters(partialPattern, patternlab); //if partial has style modifier data, replace the styleModifier value if (pattern.stylePartials && pattern.stylePartials.length > 0) { From 331eee61bc0dbd36a290f32d406afd97817e9691 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Fri, 19 May 2017 01:27:52 -0500 Subject: [PATCH 4/4] increment version number for release --- core/lib/patternlab.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/patternlab.js b/core/lib/patternlab.js index 6ee8d5d44..49641b820 100644 --- a/core/lib/patternlab.js +++ b/core/lib/patternlab.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v2.9.2 - 2017 + * patternlab-node - v2.9.3 - 2017 * * Brian Muenzenmeyer, Geoff Pursell, Raphael Okon, tburny and the web community. * Licensed under the MIT license. diff --git a/package.json b/package.json index 8c856442d..9d4357750 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "patternlab-node", "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", - "version": "2.9.2", + "version": "2.9.3", "main": "./core/lib/patternlab.js", "dependencies": { "chalk": "^1.1.3",