Skip to content

Commit 134e01a

Browse files
committed
Fix issue where partials containing styleModifiers with integers were not found correctly under all circumstances
added unit test, confirmed with shipped patterns too closes #211
1 parent ddfd363 commit 134e01a

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

CHANGELOG

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

3+
PL-node-v1.0.1
4+
- FIX: Fix issue where partials containing styleModifiers with integers were not found correctly under all circumstances
5+
36
PL-node-v1.0.0
47
- FIX: Resolve issue with not hiding underscored patterns.
58
- THX: Thanks @ivancamilov for reporting this regression.

builder/pattern_assembler.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v1.0.0 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.0 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

@@ -204,7 +204,7 @@
204204

205205
//do something with the regular old partials
206206
for(i = 0; i < foundPatternPartials.length; i++){
207-
var partialKey = foundPatternPartials[i].replace(/{{>([ ])?([\w\-\.\/~]+)(:[A-z-_|]+)?(?:\:[A-Za-z0-9-_]+)?(?:(| )\(.*)?([ ])?}}/g, '$2');
207+
var partialKey = foundPatternPartials[i].replace(/{{>([ ])?([\w\-\.\/~]+)(:[A-z0-9-_|]+)?(?:\:[A-Za-z0-9-_]+)?(?:(| )\(.*)?([ ])?}}/g, '$2');
208208

209209
var partialPath;
210210

package.gulp.json

Lines changed: 1 addition & 1 deletion
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": "1.0.0",
4+
"version": "1.0.1",
55
"devDependencies": {
66
"browser-sync": "^2.10.0",
77
"del": "^2.0.2",

package.json

Lines changed: 1 addition & 1 deletion
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": "1.0.0",
4+
"version": "1.0.1",
55
"devDependencies": {
66
"bs-html-injector": "^3.0.0",
77
"diveSync": "^0.3.0",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="test_group">
2+
{{> test-styled-atom:foo1 }}
3+
{{> test-styled-atom:foo1|foo2 }}
4+
{{> test-styled-atom:foo1|foo2(message: "bar") }}
5+
</div>

test/pattern_assembler_tests.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,41 @@
319319
test.equals(groupPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
320320
test.done();
321321
},
322+
'processPatternRecursive - correctly replaces multiple stylemodifier classes on same partial' : function(test){
323+
//arrange
324+
var fs = require('fs-extra');
325+
var pattern_assembler = new pa();
326+
var patterns_dir = './test/files/_patterns';
327+
328+
var pl = {};
329+
pl.config = {};
330+
pl.data = {};
331+
pl.data.link = {};
332+
pl.config.debug = false;
333+
pl.patterns = [];
334+
pl.config.patterns = { source: patterns_dir};
335+
336+
var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
337+
atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
338+
atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
339+
atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern);
340+
341+
var groupPattern = new object_factory.oPattern('test/files/_patterns/00-test/10-multiple-classes-numeric.mustache', '00-test', '10-multiple-classes-numeric.mustache');
342+
groupPattern.template = fs.readFileSync(patterns_dir + '/00-test/10-multiple-classes-numeric.mustache', 'utf8');
343+
groupPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(groupPattern);
344+
groupPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(groupPattern);
345+
346+
pl.patterns.push(atomPattern);
347+
pl.patterns.push(groupPattern);
348+
349+
//act
350+
pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/10-multiple-classes-numeric.mustache', pl, {});
351+
352+
//assert
353+
var expectedValue = '<div class="test_group"> <span class="test_base foo1"> {{message}} </span> <span class="test_base foo1 foo2"> {{message}} </span> <span class="test_base foo1 foo2"> bar </span> </div>';
354+
test.equals(groupPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
355+
test.done();
356+
},
322357
'processPatternRecursive - correctly ignores a partial without a style modifier when the same partial later has a style modifier' : function(test){
323358
//arrange
324359
var fs = require('fs-extra');

0 commit comments

Comments
 (0)