Skip to content

Commit

Permalink
Merge pull request #664 from pattern-lab/dev
Browse files Browse the repository at this point in the history
Pattern Lab Node 2.9.3
  • Loading branch information
bmuenzenmeyer authored May 19, 2017
2 parents 3a1a92a + 331eee6 commit ec0c7b6
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 13 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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)
3 changes: 3 additions & 0 deletions core/lib/parameter_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion core/lib/patternlab.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions test/files/_patterns/00-test/539-a.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<b>a</b>
{{ #a }}
<i>a!</i>
{{ /a }}
5 changes: 5 additions & 0 deletions test/files/_patterns/00-test/539-b.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<b>b</b>
{{ #b }}
<i>b!</i>
{{ /b }}
{{> test-a(a: true) }}
2 changes: 2 additions & 0 deletions test/files/_patterns/00-test/539-c.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<b>c</b>
{{> test-b(b: true) }}
64 changes: 62 additions & 2 deletions test/parameter_hunter_tests.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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()
}
};

Expand All @@ -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,
`<b>c</b>
<b>b</b>
<i>b!</i>
<b>a</b>
<i>a!</i>
`);

test.end();
});

tap.test('parameter hunter finds and extends templates with mixed parameter and global data', function(test) {
var currentPattern = currentPatternClosure();
var patternlab = patternlabClosure();
Expand Down

0 comments on commit ec0c7b6

Please sign in to comment.