Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7454424
Add editorconfig and eslintrc
geoffp Aug 25, 2015
4a9dec6
Add first draft of pattern engines
geoffp Aug 25, 2015
4899cd9
first batch of changes to migrate from direct dependence on mustache to
geoffp Aug 25, 2015
30f8000
First steps toward a .render() method directly on the oPattern
geoffp Aug 28, 2015
5420ad1
comment fixups
geoffp Sep 21, 2015
d022308
Merge tag 'v0.12.0' into pattern-engines
geoffp Sep 21, 2015
3452046
Merge branch 'master' into pattern-engines
geoffp Oct 6, 2015
a2f5cf7
fix typos and module path issues
geoffp Oct 27, 2015
6a6db63
make PatternEngines a genuine Object, and set up its method-bearing p…
geoffp Oct 27, 2015
f22551b
temporarily restore mustache-only pattern rendering
geoffp Oct 27, 2015
a7236f7
'working' renderPattern function
geoffp Oct 27, 2015
fd5e6b6
start rendering real oPatterns and fix that rendering path
geoffp Oct 27, 2015
c4d5080
add file extension to oPattern, update unit test
geoffp Oct 27, 2015
37bacdc
Create a new mapping between file extensions and engine names at load
geoffp Oct 27, 2015
f54db83
Add unit tests for pattern_engines.js and individual pattern engines
geoffp Oct 27, 2015
9d0eff3
Merge remote-tracking branch 'remotes/upstream/pattern-engines' into …
geoffp Nov 16, 2015
5217108
isPatternFile consolidation and tests
geoffp Nov 16, 2015
ac54ffb
We now pass all tests and build "successfully," but pseudo-patterns
geoffp Nov 17, 2015
eb52998
a little progress on the pseudo-pattern problem. They render now, but
geoffp Nov 17, 2015
2cca3cb
eliminate redundant "is this really a pattern" checking
geoffp Nov 17, 2015
861a146
misc
geoffp Nov 17, 2015
a648ae5
fix homepage pattern and its pseudo-pattern not rendering
geoffp Nov 17, 2015
7989cfb
a little more leniency from eslint
geoffp Nov 25, 2015
b37e5d7
Factor the finders out of pattern_assembler and add them as methods on
geoffp Nov 25, 2015
2c04ac1
Beef up all the unit tests -- use the new oPattern factories rather than
geoffp Nov 25, 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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
72 changes: 72 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"env": {
"jasmine": true,
"node": true,
"mocha": true,
"browser": true,
"builtin": true
},
"globals": {},
"rules": {
"block-scoped-var": 2,
"camelcase": 0,
"curly": [
2,
"all"
],
"dot-notation": [
2,
{
"allowKeywords": true
}
],
"eqeqeq": [
2,
"allow-null"
],
"global-strict": [
2,
"never"
],
"guard-for-in": 2,
"new-cap": 0,
"no-bitwise": 2,
"no-caller": 2,
"no-cond-assign": [
2,
"except-parens"
],
"no-debugger": 2,
"no-empty": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-parens": 0,
"no-irregular-whitespace": 1,
"no-iterator": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-multi-spaces": 0,
"no-new": 2,
"no-proto": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-with": 2,
"quotes": [
0,
"single"
],
"semi": [
0,
"never"
],
"strict": 2,
"valid-typeof": 2,
"wrap-iife": [
2,
"inside"
]
}
}
15 changes: 8 additions & 7 deletions builder/lineage_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.14.0 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand All @@ -19,7 +19,8 @@
var pattern_assembler = new pa();

//find the {{> template-name }} within patterns
var matches = pattern_assembler.find_pattern_partials(pattern);
console.log('===\n', pattern, '\n===');
var matches = pattern.findPartials();
if(matches !== null){
matches.forEach(function(match, index, matches){
//strip out the template cruft
Expand Down
34 changes: 19 additions & 15 deletions builder/list_item_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.14.0 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand All @@ -14,20 +14,23 @@
var list_item_hunter = function(){

var extend = require('util')._extend,
pa = require('./pattern_assembler'),
smh = require('./style_modifier_hunter'),
mustache = require('mustache'),
pattern_assembler = new pa(),
style_modifier_hunter = new smh(),
items = [ 'zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];
pa = require('./pattern_assembler'),
smh = require('./style_modifier_hunter'),
config = require('../config.json'),
of = require('./object_factory');

var pattern_assembler = new pa(),
style_modifier_hunter = new smh(),
items = [ 'zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];

function processListItemPartials(pattern, patternlab){
//find any listitem blocks
var matches = pattern_assembler.find_list_items(pattern, patternlab);
var matches = pattern.findListItems();

if(matches !== null){
matches.forEach(function(liMatch, index, matches){

if(patternlab.config.debug){
if(config.debug){
console.log('found listItem of size ' + liMatch + ' inside ' + pattern.key);
}

Expand All @@ -39,6 +42,7 @@
var repeatedBlockTemplate = [];
var repeatedBlockHtml = '';
for(var i = 0; i < items.indexOf(loopNumberString); i++){
console.log('adding', patternBlock, 'to repeatedBlockTemplate');
repeatedBlockTemplate.push(patternBlock);
}

Expand All @@ -62,7 +66,7 @@
allData.link = extend({}, patternlab.data.link);

//check for partials within the repeated block
var foundPartials = pattern_assembler.find_pattern_partials({ 'template' : thisBlockTemplate });
var foundPartials = of.oPattern.createEmpty({'template': thisBlockTemplate}).findPartials();

if(foundPartials && foundPartials.length > 0){

Expand Down
74 changes: 67 additions & 7 deletions builder/object_factory.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
/*
* patternlab-node - v0.14.0 - 2015
*
/*
* patternlab-node - v0.14.0 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

(function () {
"use strict";

var patternEngines = require('./pattern_engines/pattern_engines');
var path = require('path');
var fs = require('fs-extra');
var config = fs.readJSONSync('./config.json');
var extend = require('util')._extend;

// oPattern properties

var oPattern = function(abspath, subdir, filename, data){
if (config.debug) {
console.log('=== NEW OPATTERN.', '\nabsPath:', abspath, '\nsubdir:', subdir, '\nfilename:', filename, '\ndata:\n', data);
}
this.fileName = filename.substring(0, filename.indexOf('.'));
this.fileExtension = path.extname(abspath);
this.abspath = abspath;
this.subdir = subdir;
this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir
Expand All @@ -32,7 +44,52 @@
this.lineageIndex = [];
this.lineageR = [];
this.lineageRIndex = [];
this.isPseudoPattern = false;
this.engine = patternEngines.getEngineForPattern(this);
};

// 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 ===');
}
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

// factory: creates an empty oPattern for miscellaneous internal use, such as
// by list_item_hunter
oPattern.createEmpty = function (customProps) {
var pattern = new oPattern('', '', '', null);
return extend(pattern, customProps);
};

// factory: creates an oPattern object on-demand from a hash; the hash accepts
// parameters that replace the positional parameters that the oPattern
// constructor takes.
oPattern.create = function (abspath, subdir, filename, data, customProps) {
var newPattern = new oPattern(abspath || '', subdir || '', filename || '', data || null);
return extend(newPattern, customProps);
};


var oBucket = function(name){
this.bucketNameLC = name;
Expand All @@ -45,6 +102,7 @@
this.patternItemsIndex = [];
};


var oNavItem = function(name){
this.sectionNameLC = name;
this.sectionNameUC = name.split('-').reduce(function(val, working){
Expand All @@ -54,6 +112,7 @@
this.navSubItemsIndex = [];
};


var oNavSubItem = function(name){
this.patternPath = '';
this.patternPartial = '';
Expand All @@ -62,11 +121,12 @@
}, '').trim();
};


module.exports = {
oPattern: oPattern,
oBucket: oBucket,
oNavItem: oNavItem,
oNavSubItem: oNavSubItem
};

}());
})();
6 changes: 3 additions & 3 deletions builder/parameter_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* patternlab-node - v0.14.0 - 2015
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
Loading