Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PatternEngines ongoing work, round 3 #199

Merged
merged 29 commits into from
Dec 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6c61d19
Remove extra/unnecessary word
Nov 8, 2015
beb6d7e
Merge pull request #179 from gobrendan/master
Nov 9, 2015
d5de173
Updated package.json devDependencies for grunt and gulp configurations.
bmuenzenmeyer Nov 12, 2015
9b1d6a9
Updated the changelog and readme to reflext node 4 and 5 support.
bmuenzenmeyer Nov 12, 2015
56c0efa
bumped the version
bmuenzenmeyer Nov 12, 2015
0afb234
pushed the travis config with more node options.
bmuenzenmeyer Nov 12, 2015
3912333
Merge pull request #181 from pattern-lab/dev
Nov 12, 2015
e5ac6be
fix issue with style modifiers not working with spaces in the template
bmuenzenmeyer Nov 17, 2015
3c3270a
added a note to CONTRIBUTING.md that mentions up for grabs issues
bmuenzenmeyer Nov 17, 2015
a818d28
support for multiple classes on stylemodifier
bmuenzenmeyer Nov 17, 2015
157a06e
updated the instructions to point to the wiki for now
bmuenzenmeyer Nov 17, 2015
8fb7eea
Unit test to cover correct application of multiple partials with diff…
bmuenzenmeyer Nov 25, 2015
ffc80cb
a unit test to cover half of #190
bmuenzenmeyer Nov 25, 2015
9cd187b
additional tests to cover styleModifier / pattern Parameter relationship
bmuenzenmeyer Nov 25, 2015
8584231
looks like there are some newlines on the CI box that are not on my W…
bmuenzenmeyer Nov 25, 2015
e8f060f
Merge pull request #195 from pattern-lab/dev
Nov 25, 2015
e8f99c1
Remove unused module requires -- that's the last of the direct couplings
geoffp Dec 1, 2015
96c88c0
Migrate some things to a nicer object literal syntax; use the oPattern
geoffp Dec 1, 2015
d7a531e
factor utility functions out of the pattern assembler and put 'em in our
geoffp Dec 1, 2015
0ffb2fe
have eslint chill out about a couple things
geoffp Dec 1, 2015
b03bc45
New partial finding regex for Mustache that accounts for regular syntax,
geoffp Dec 1, 2015
882aee2
streamline, DRY out and update unit tests
geoffp Dec 1, 2015
fd3c4b5
unit test fixups, plus a tweak to the Mustache partial finder to permit
geoffp Dec 2, 2015
ee6fcfc
fix for out-of-order pseudopattern bug -- isPatternFile() should return
geoffp Dec 3, 2015
75d90a2
Note verbose syntax in unit test
geoffp Dec 3, 2015
ded3224
Fix (?) partial name; unit test now passes
geoffp Dec 3, 2015
0681781
Merge remote-tracking branch 'refs/remotes/upstream/master' into patt…
geoffp Dec 4, 2015
b2e1a38
Fix the 'process_list_item_partials finds verbose partials and outputs
geoffp Dec 4, 2015
bdb0b7b
Factor getPartialKey out of pattern assembler -- it's Mustache-specific
geoffp Dec 4, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"all"
],
"dot-notation": [
2,
1,
{
"allowKeywords": true
}
Expand All @@ -29,6 +29,7 @@
"never"
],
"guard-for-in": 2,
"key-spacing": 1,
"new-cap": 0,
"no-bitwise": 2,
"no-caller": 2,
Expand All @@ -52,6 +53,7 @@
"no-sequences": 2,
"no-shadow": 2,
"no-undef": 2,
"no-underscore-dangle": 1,
"no-unused-vars": 2,
"no-with": 2,
"quotes": [
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js

node_js:
- stable
- 4.0
- 0.12
- 0.11

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.

PL-node-v0.15.1
- FIX: Resolve issue with styleModifiers not being replaced when the partial has spaces in it.
- ADD: Support multiple styleModifier classes using the | pipe syntax
- FIX: Resolve issue with styleModifiers not being applied correctly when mixed with pattern parameters
- THX: Thanks @theorise for the issue reports!

PL-node-v0.15.0
- CHG: Updated package.json devDependencies for Node 4.X and 5.X support.
- CHG: Updated package.gulp.json devDependencies for Node 4.X and 5.X support.

PL-node-v0.14.0
- ADD: Support for style modifiers
- ADD: Support for styleGuideExcludes
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Contributing to Patternlab - Node
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.

No pull request is too small.
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.

##Guidelines
1. Please keep your pull requests concise and limited to **ONE** substantive change at a time.
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ 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.
* **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).

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

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.

**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.

### Getting Started - Grunt

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

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.
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.

### Getting Started - Gulp

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

### Upgrading

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)
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)

### Command Line Interface

Expand Down Expand Up @@ -214,6 +212,11 @@ Once rendered, it looks like this:
</div>
```

You may also specify multiple classes using a pipe character (|).

```
{{> atoms-message:error|is-on }}
```



Expand Down
11 changes: 7 additions & 4 deletions builder/lineage_hunter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.15.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
Expand All @@ -17,9 +17,12 @@

var pa = require('./pattern_assembler');
var pattern_assembler = new pa();
var config = require('../config.json');

//find the {{> template-name }} within patterns
console.log('===\n', pattern, '\n===');
if (config.debug) {
console.log('===\n', pattern, '\n===');
}
var matches = pattern.findPartials();
if(matches !== null){
matches.forEach(function(match, index, matches){
Expand Down
17 changes: 10 additions & 7 deletions builder/list_item_hunter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.15.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
Expand All @@ -16,6 +16,7 @@
var extend = require('util')._extend,
pa = require('./pattern_assembler'),
smh = require('./style_modifier_hunter'),
plutils = require('./utilities'),
config = require('../config.json'),
of = require('./object_factory');

Expand All @@ -42,13 +43,15 @@
var repeatedBlockTemplate = [];
var repeatedBlockHtml = '';
for(var i = 0; i < items.indexOf(loopNumberString); i++){
console.log('adding', patternBlock, 'to repeatedBlockTemplate');
if (config.debug) {
console.log('list item(s) in pattern', pattern.patternName, 'adding', patternBlock, 'to repeatedBlockTemplate');
}
repeatedBlockTemplate.push(patternBlock);
}

//check for a local listitems.json file
var listData = JSON.parse(JSON.stringify(patternlab.listitems));
listData = pattern_assembler.merge_data(listData, pattern.listitems);
listData = plutils.mergeData(listData, pattern.listitems);

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

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

//check for partials within the repeated block
Expand Down
2 changes: 1 addition & 1 deletion builder/media_hunter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.14.0 - 2015
* patternlab-node - v0.15.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
55 changes: 33 additions & 22 deletions builder/object_factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v0.14.0 - 2015
* patternlab-node - v0.15.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -19,7 +19,7 @@

// oPattern properties

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

// oPattern methods

// render method on oPatterns; this acts as a proxy for the PatternEngine's
// render function
oPattern.prototype.render = function (data, partials) {
if (config.debug && this.isPseudoPattern) {
console.log('===', this.name + ' IS A PSEUDO-PATTERN ===');
oPattern.prototype = {

// render method on oPatterns; this acts as a proxy for the PatternEngine's
// render function
render: function (data, partials) {
if (config.debug && this.isPseudoPattern) {
console.log('===', this.name + ' IS A PSEUDO-PATTERN ===');
}
return this.engine.renderPattern(this.extendedTemplate, data, partials);
},

// the finders all delegate to the PatternEngine, which also encapsulates all
// appropriate regexes
findPartials: function () {
return this.engine.findPartials(this);
},

findPartialsWithStyleModifiers: function () {
return this.engine.findPartialsWithStyleModifiers(this);
},

findPartialsWithPatternParameters: function () {
return this.engine.findPartialsWithPatternParameters(this);
},

findListItems: function () {
return this.engine.findListItems(this);
},

getPartialKey: function (partialString) {
return this.engine.getPartialKey(this, partialString);
}
return this.engine.renderPattern(this.extendedTemplate, data, partials);
};
// the finders all delegate to the PatternEngine, which also encapsulates all
// appropriate regexes
oPattern.prototype.findPartials = function () {
return this.engine.findPartials(this);
};
oPattern.prototype.findPartialsWithStyleModifiers = function () {
return this.engine.findPartialsWithStyleModifiers(this);
};
oPattern.prototype.findPartialsWithPatternParameters = function () {
return this.engine.findPartialsWithPatternParameters(this);
};
oPattern.prototype.findListItems = function () {
return this.engine.findListItems(this);
};

// oPattern static methods
Expand Down
14 changes: 8 additions & 6 deletions builder/parameter_hunter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.15.1 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
Expand All @@ -15,8 +15,8 @@

var extend = require('util')._extend,
pa = require('./pattern_assembler'),
mustache = require('mustache'),
smh = require('./style_modifier_hunter'),
plutils = require('./utilities'),
style_modifier_hunter = new smh(),
pattern_assembler = new pa();

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

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

var allData = pattern_assembler.merge_data(globalData, localData);
allData = pattern_assembler.merge_data(allData, paramData);
var allData = plutils.mergeData(globalData, localData);
allData = plutils.mergeData(allData, paramData);

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