Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit b807680

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #199 from geoffp/pattern-engines
PatternEngines ongoing work, round 3
2 parents 3d9753a + bdb0b7b commit b807680

35 files changed

+748
-530
lines changed

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"all"
1616
],
1717
"dot-notation": [
18-
2,
18+
1,
1919
{
2020
"allowKeywords": true
2121
}
@@ -29,6 +29,7 @@
2929
"never"
3030
],
3131
"guard-for-in": 2,
32+
"key-spacing": 1,
3233
"new-cap": 0,
3334
"no-bitwise": 2,
3435
"no-caller": 2,
@@ -52,6 +53,7 @@
5253
"no-sequences": 2,
5354
"no-shadow": 2,
5455
"no-undef": 2,
56+
"no-underscore-dangle": 1,
5557
"no-unused-vars": 2,
5658
"no-with": 2,
5759
"quotes": [

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22

33
node_js:
4+
- stable
5+
- 4.0
46
- 0.12
57
- 0.11
68

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

3+
PL-node-v0.15.1
4+
- FIX: Resolve issue with styleModifiers not being replaced when the partial has spaces in it.
5+
- ADD: Support multiple styleModifier classes using the | pipe syntax
6+
- FIX: Resolve issue with styleModifiers not being applied correctly when mixed with pattern parameters
7+
- THX: Thanks @theorise for the issue reports!
8+
9+
PL-node-v0.15.0
10+
- CHG: Updated package.json devDependencies for Node 4.X and 5.X support.
11+
- CHG: Updated package.gulp.json devDependencies for Node 4.X and 5.X support.
12+
313
PL-node-v0.14.0
414
- ADD: Support for style modifiers
515
- ADD: Support for styleGuideExcludes

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Contributing to Patternlab - Node
22
If you'd like to contribute to patternlab - node, please do so! There is always a lot of ground to cover, with patternlab - php being so feature-rich.
33

4-
No pull request is too small.
4+
No pull request is too small. Check out any [up for grabs issues](https://github.com/pattern-lab/patternlab-node/labels/up%20for%20grabs) as a good way to get your feet wet.
55

66
##Guidelines
77
1. Please keep your pull requests concise and limited to **ONE** substantive change at a time.

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ This repository contains the vanilla builder logic, grunt and gulp configuration
1010

1111
* Download the [latest release of patternlab-node](https://github.com/pattern-lab/patternlab-node/releases/latest) from Github
1212
* Via npm, run `npm install patternlab-node` (Note this will auto install the grunt version currently. see below)
13-
* **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.
13+
* **NOTE** Node version 4.X and 5.X have tentative support, 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. I've tried to catalog some issues and troubleshooting steps on the [wiki](https://github.com/pattern-lab/patternlab-node/wiki/Windows-Issues).
1414

1515
### Choose Your Adventure! Now Vanilla, Grunt & Gulp
1616

1717
This repository ships with two `package.json` files, a `Gruntfile.js`, and a `gulpfile.js`. The default is grunt currently. The core builder is not dependent on either.
1818

19-
**HELP WANTED** Please help me test both of the configurations by [reporting](https://github.com/pattern-lab/patternlab-node/blob/dev/CONTRIBUTING.md) any issues encountered.
20-
2119
### Getting Started - Grunt
2220

2321
To run patternlab-node using grunt, do the following in the directory you downloaded and extracted the zipped release:
@@ -27,7 +25,7 @@ To run patternlab-node using grunt, do the following in the directory you downlo
2725
* Not deleting `builder/patternlab_gulp.js` may cause a harmless error when running grunt. Delete it.
2826
3. Run `grunt` or `grunt serve` from the command line
2927

30-
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to see have BrowserSync spin up and serve the files to you.
28+
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to have BrowserSync spin up and serve the files to you.
3129

3230
### Getting Started - Gulp
3331

@@ -51,7 +49,7 @@ It's not expected to toggle between the two build systems, but for those migrati
5149

5250
### Upgrading
5351

54-
You can find some simple upgrade documenation in it's current home here (unreleased but confirmed to work): [https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md](https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md)
52+
You can find instructions on how to upgrade from version to version of Pattern Lab Node here: [https://github.com/pattern-lab/patternlab-node/wiki/Upgrading](https://github.com/pattern-lab/patternlab-node/wiki/Upgrading)
5553

5654
### Command Line Interface
5755

@@ -214,6 +212,11 @@ Once rendered, it looks like this:
214212
</div>
215213
```
216214

215+
You may also specify multiple classes using a pipe character (|).
216+
217+
```
218+
{{> atoms-message:error|is-on }}
219+
```
217220

218221

219222

builder/lineage_hunter.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v0.14.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v0.15.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -17,9 +17,12 @@
1717

1818
var pa = require('./pattern_assembler');
1919
var pattern_assembler = new pa();
20+
var config = require('../config.json');
2021

2122
//find the {{> template-name }} within patterns
22-
console.log('===\n', pattern, '\n===');
23+
if (config.debug) {
24+
console.log('===\n', pattern, '\n===');
25+
}
2326
var matches = pattern.findPartials();
2427
if(matches !== null){
2528
matches.forEach(function(match, index, matches){

builder/list_item_hunter.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v0.14.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v0.15.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -16,6 +16,7 @@
1616
var extend = require('util')._extend,
1717
pa = require('./pattern_assembler'),
1818
smh = require('./style_modifier_hunter'),
19+
plutils = require('./utilities'),
1920
config = require('../config.json'),
2021
of = require('./object_factory');
2122

@@ -42,13 +43,15 @@
4243
var repeatedBlockTemplate = [];
4344
var repeatedBlockHtml = '';
4445
for(var i = 0; i < items.indexOf(loopNumberString); i++){
45-
console.log('adding', patternBlock, 'to repeatedBlockTemplate');
46+
if (config.debug) {
47+
console.log('list item(s) in pattern', pattern.patternName, 'adding', patternBlock, 'to repeatedBlockTemplate');
48+
}
4649
repeatedBlockTemplate.push(patternBlock);
4750
}
4851

4952
//check for a local listitems.json file
5053
var listData = JSON.parse(JSON.stringify(patternlab.listitems));
51-
listData = pattern_assembler.merge_data(listData, pattern.listitems);
54+
listData = plutils.mergeData(listData, pattern.listitems);
5255

5356
//iterate over each copied block, rendering its contents along with pattenlab.listitems[i]
5457
for(var i = 0; i < repeatedBlockTemplate.length; i++){
@@ -61,8 +64,8 @@
6164
var globalData = JSON.parse(JSON.stringify(patternlab.data));
6265
var localData = JSON.parse(JSON.stringify(pattern.jsonFileData));
6366

64-
var allData = pattern_assembler.merge_data(globalData, localData);
65-
allData = pattern_assembler.merge_data(allData, itemData != undefined ? itemData[i] : {}); //itemData could be undefined if the listblock contains no partial, just markup
67+
var allData = plutils.mergeData(globalData, localData);
68+
allData = plutils.mergeData(allData, itemData != undefined ? itemData[i] : {}); //itemData could be undefined if the listblock contains no partial, just markup
6669
allData.link = extend({}, patternlab.data.link);
6770

6871
//check for partials within the repeated block

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.14.0 - 2015
2+
* patternlab-node - v0.15.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.14.0 - 2015
2+
* patternlab-node - v0.15.1 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -19,7 +19,7 @@
1919

2020
// oPattern properties
2121

22-
var oPattern = function(abspath, subdir, filename, data){
22+
var oPattern = function(abspath, subdir, filename, data) {
2323
if (config.debug) {
2424
console.log('=== NEW OPATTERN.', '\nabsPath:', abspath, '\nsubdir:', subdir, '\nfilename:', filename, '\ndata:\n', data);
2525
}
@@ -50,27 +50,38 @@
5050

5151
// oPattern methods
5252

53-
// render method on oPatterns; this acts as a proxy for the PatternEngine's
54-
// render function
55-
oPattern.prototype.render = function (data, partials) {
56-
if (config.debug && this.isPseudoPattern) {
57-
console.log('===', this.name + ' IS A PSEUDO-PATTERN ===');
53+
oPattern.prototype = {
54+
55+
// render method on oPatterns; this acts as a proxy for the PatternEngine's
56+
// render function
57+
render: function (data, partials) {
58+
if (config.debug && this.isPseudoPattern) {
59+
console.log('===', this.name + ' IS A PSEUDO-PATTERN ===');
60+
}
61+
return this.engine.renderPattern(this.extendedTemplate, data, partials);
62+
},
63+
64+
// the finders all delegate to the PatternEngine, which also encapsulates all
65+
// appropriate regexes
66+
findPartials: function () {
67+
return this.engine.findPartials(this);
68+
},
69+
70+
findPartialsWithStyleModifiers: function () {
71+
return this.engine.findPartialsWithStyleModifiers(this);
72+
},
73+
74+
findPartialsWithPatternParameters: function () {
75+
return this.engine.findPartialsWithPatternParameters(this);
76+
},
77+
78+
findListItems: function () {
79+
return this.engine.findListItems(this);
80+
},
81+
82+
getPartialKey: function (partialString) {
83+
return this.engine.getPartialKey(this, partialString);
5884
}
59-
return this.engine.renderPattern(this.extendedTemplate, data, partials);
60-
};
61-
// the finders all delegate to the PatternEngine, which also encapsulates all
62-
// appropriate regexes
63-
oPattern.prototype.findPartials = function () {
64-
return this.engine.findPartials(this);
65-
};
66-
oPattern.prototype.findPartialsWithStyleModifiers = function () {
67-
return this.engine.findPartialsWithStyleModifiers(this);
68-
};
69-
oPattern.prototype.findPartialsWithPatternParameters = function () {
70-
return this.engine.findPartialsWithPatternParameters(this);
71-
};
72-
oPattern.prototype.findListItems = function () {
73-
return this.engine.findListItems(this);
7485
};
7586

7687
// oPattern static methods

builder/parameter_hunter.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
* patternlab-node - v0.14.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v0.15.1 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
66
*
@@ -15,8 +15,8 @@
1515

1616
var extend = require('util')._extend,
1717
pa = require('./pattern_assembler'),
18-
mustache = require('mustache'),
1918
smh = require('./style_modifier_hunter'),
19+
plutils = require('./utilities'),
2020
style_modifier_hunter = new smh(),
2121
pattern_assembler = new pa();
2222

@@ -28,6 +28,8 @@
2828
//find the partial's name and retrieve it
2929
var partialName = pMatch.match(/([\w\-\.\/~]+)/g)[0];
3030
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
31+
//if we retrieved a pattern we should make sure that its extendedTemplate is reset. looks to fix #190
32+
partialPattern.extendedTemplate = partialPattern.template;
3133

3234
if(patternlab.config.debug){
3335
console.log('found patternParameters for ' + partialName);
@@ -44,8 +46,8 @@
4446
var globalData = JSON.parse(JSON.stringify(patternlab.data));
4547
var localData = JSON.parse(JSON.stringify(pattern.jsonFileData || {}));
4648

47-
var allData = pattern_assembler.merge_data(globalData, localData);
48-
allData = pattern_assembler.merge_data(allData, paramData);
49+
var allData = plutils.mergeData(globalData, localData);
50+
allData = plutils.mergeData(allData, paramData);
4951

5052
//if partial has style modifier data, replace the styleModifier value
5153
if(pattern.stylePartials && pattern.stylePartials.length > 0){

0 commit comments

Comments
 (0)