Skip to content

Pattern Lab Node Core 2.5.1 #465

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

Merged
merged 2 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ var pattern_assembler = function () {
//create a copy of the partial so as to not pollute it after the getPartial call.
var partialPattern = getPartial(partial, patternlab);
var cleanPartialPattern = JSON5.parse(JSON5.stringify(partialPattern));
cleanPartialPattern.extendedTemplate = cleanPartialPattern.template;

//if partial has style modifier data, replace the styleModifier value
if (currentPattern.stylePartials && currentPattern.stylePartials.length > 0) {
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.5.0 - 2016
* patternlab-node - v2.5.1 - 2016
*
* Brian Muenzenmeyer, Geoff Pursell, 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.5.0",
"version": "2.5.1",
"main": "./core/lib/patternlab.js",
"dependencies": {
"diveSync": "^0.3.0",
Expand Down
1 change: 1 addition & 0 deletions test/files/_patterns/00-test/14-inception.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> test-foo }}
70 changes: 69 additions & 1 deletion test/pattern_assembler_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,77 @@
//assert
var expectedCleanValue = '<span class="test_base {{styleModifier}}"> {{message}} </span>';
var expectedSetValue = '<span class="test_base test_1"> {{message}} </span>';
test.equals(anotherPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedSetValue.trim());

//this is the "atom" - it should remain unchanged
test.equals(atomPattern.template.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedCleanValue.trim());
test.equals(atomPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedCleanValue.trim());

// this is the style modifier pattern, which should resolve correctly
test.equals(anotherPattern.template.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), '{{> test-styled-atom:test_1 }}');
test.equals(anotherPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedSetValue.trim());

test.done();
},
'processPatternRecursive - ensure deep-nesting works' : function(test){
//arrange
var fs = require('fs-extra');
var pattern_assembler = new pa();
var patterns_dir = './test/files/_patterns';

var pl = {};
pl.config = {
paths: {
source: {
patterns: patterns_dir
}
},
outputFileSuffixes: {
rendered : ''
}
};
pl.data = {};
pl.data.link = {};
pl.config.debug = false;
pl.patterns = [];
pl.partials = {};

var atomPattern = new Pattern('00-test/01-bar.mustache');
atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/01-bar.mustache', 'utf8');
atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern);

var templatePattern = new Pattern('00-test/00-foo.mustache');
templatePattern.template = fs.readFileSync(patterns_dir + '/00-test/00-foo.mustache', 'utf8');
templatePattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(templatePattern);
templatePattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(templatePattern);

var pagesPattern = new Pattern('00-test/14-inception.mustache');
pagesPattern.template = fs.readFileSync(patterns_dir + '/00-test/14-inception.mustache', 'utf8');
pagesPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(pagesPattern);
pagesPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(pagesPattern);

pattern_assembler.addPattern(atomPattern, pl);
pattern_assembler.addPattern(templatePattern, pl);
pattern_assembler.addPattern(pagesPattern, pl);

//act
pattern_assembler.process_pattern_recursive('00-test' + path.sep + '14-inception.mustache', pl, {});

//assert
var expectedCleanValue = 'bar';
var expectedSetValue = 'bar';

//this is the "atom" - it should remain unchanged
test.equals(atomPattern.template.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedCleanValue);
test.equals(atomPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedCleanValue);

//this is the "template pattern" - it should have an updated extendedTemplate but an unchanged template
test.equals(templatePattern.template.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), '{{> test-bar }}');
test.equals(templatePattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedSetValue.trim());

//this is the "pages pattern" - it should have an updated extendedTemplate equal to the template pattern but an unchanged template
test.equals(pagesPattern.template.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), '{{> test-foo }}');
test.equals(pagesPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedSetValue.trim());
test.done();
},
'setState - applies any patternState matching the pattern' : function(test){
Expand Down