Skip to content

Commit ec0c7b6

Browse files
Merge pull request #664 from pattern-lab/dev
Pattern Lab Node 2.9.3
2 parents 3a1a92a + 331eee6 commit ec0c7b6

File tree

8 files changed

+87
-13
lines changed

8 files changed

+87
-13
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ This repository contains the core functionality for Pattern Lab Node. Pattern La
88

99
[Online Demo of Pattern Lab Output](http://demo.patternlab.io/)
1010

11+
## Support for Pattern Lab Node
12+
13+
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).
14+
15+
**:100: Thanks for support from the following:**
16+
17+
* **[Brad Frost](http://bradfrost.com/)**
18+
* Marcos Peebles
19+
1120
## Installation
1221

1322
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
8493

8594
Ask or answer Pattern Lab questions on Stack Overflow: http://stackoverflow.com/questions/tagged/patternlab.io
8695

87-
## Support Pattern Lab Node
88-
89-
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.
90-
91-
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.
92-
93-
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.
94-
- [Pattern Lab on Patreon](https://www.patreon.com/patternlab)
95-
9696
## License
9797

9898
[MIT](https://github.com/pattern-lab/patternlab-node/blob/master/LICENSE)

core/lib/parameter_hunter.js

+3
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ var parameter_hunter = function () {
271271
var allData = plutils.mergeData(globalData, localData);
272272
allData = plutils.mergeData(allData, paramData);
273273

274+
//if the partial has pattern parameters itself, we need to handle those
275+
findparameters(partialPattern, patternlab);
276+
274277
//if partial has style modifier data, replace the styleModifier value
275278
if (pattern.stylePartials && pattern.stylePartials.length > 0) {
276279
style_modifier_hunter.consume_style_modifier(partialPattern, pMatch, patternlab);

core/lib/patternlab.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v2.9.2 - 2017
2+
* patternlab-node - v2.9.3 - 2017
33
*
44
* Brian Muenzenmeyer, Geoff Pursell, Raphael Okon, tburny and the web community.
55
* Licensed under the MIT license.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternlab-node",
33
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4-
"version": "2.9.2",
4+
"version": "2.9.3",
55
"main": "./core/lib/patternlab.js",
66
"dependencies": {
77
"chalk": "^1.1.3",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<b>a</b>
2+
{{ #a }}
3+
<i>a!</i>
4+
{{ /a }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<b>b</b>
2+
{{ #b }}
3+
<i>b!</i>
4+
{{ /b }}
5+
{{> test-a(a: true) }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<b>c</b>
2+
{{> test-b(b: true) }}

test/parameter_hunter_tests.js

+62-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
"use strict";
22

33
var tap = require('tap');
4+
var pa = require('../core/lib/pattern_assembler');
5+
var Pattern = require('../core/lib/object_factory').Pattern;
6+
var CompileState = require('../core/lib/object_factory').CompileState;
7+
var PatternGraph = require('../core/lib/pattern_graph').PatternGraph;
8+
9+
var fs = require('fs-extra');
410

511
var ph = require('../core/lib/parameter_hunter');
612

13+
714
//setup current pattern from what we would have during execution
815
function currentPatternClosure() {
916
return {
@@ -48,9 +55,11 @@ function patternlabClosure() {
4855
debug: false
4956
},
5057
data: {
51-
description: 'Not a quote from a smart man'
58+
description: 'Not a quote from a smart man',
59+
link: {}
5260
},
53-
partials: {}
61+
partials: {},
62+
graph: PatternGraph.empty()
5463
}
5564
};
5665

@@ -65,6 +74,57 @@ tap.test('parameter hunter finds and extends templates', function(test) {
6574
test.end();
6675
});
6776

77+
tap.test('parameter hunter finds partials with their own parameters and renders them too', function(test) {
78+
//arrange
79+
80+
var pattern_assembler = new pa();
81+
var patterns_dir = './test/files/_patterns/';
82+
83+
var pl = patternlabClosure();
84+
85+
86+
var aPattern = new Pattern('00-test/539-a.mustache');
87+
aPattern.template = fs.readFileSync(patterns_dir + '00-test/539-a.mustache', 'utf8');
88+
aPattern.extendedTemplate = aPattern.template;
89+
aPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(aPattern);
90+
aPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(aPattern);
91+
92+
var bPattern = new Pattern('00-test/539-b.mustache');
93+
bPattern.template = fs.readFileSync(patterns_dir + '00-test/539-b.mustache', 'utf8');
94+
bPattern.extendedTemplate = bPattern.template;
95+
bPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(bPattern);
96+
bPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(bPattern);
97+
98+
var cPattern = new Pattern('00-test/539-c.mustache');
99+
cPattern.template = fs.readFileSync(patterns_dir + '00-test/539-c.mustache', 'utf8');
100+
cPattern.extendedTemplate = cPattern.template;
101+
cPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(cPattern);
102+
cPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(cPattern);
103+
104+
pattern_assembler.addPattern(aPattern, pl);
105+
pattern_assembler.addPattern(bPattern, pl);
106+
pattern_assembler.addPattern(cPattern, pl);
107+
108+
var currentPattern = cPattern;
109+
var parameter_hunter = new ph();
110+
111+
//act
112+
parameter_hunter.find_parameters(currentPattern, pl);
113+
114+
//assert
115+
test.equals(currentPattern.extendedTemplate,
116+
`<b>c</b>
117+
<b>b</b>
118+
<i>b!</i>
119+
<b>a</b>
120+
<i>a!</i>
121+
122+
123+
`);
124+
125+
test.end();
126+
});
127+
68128
tap.test('parameter hunter finds and extends templates with mixed parameter and global data', function(test) {
69129
var currentPattern = currentPatternClosure();
70130
var patternlab = patternlabClosure();

0 commit comments

Comments
 (0)