Skip to content

Commit 454292e

Browse files
refactor: remove styleModifiers (#1452)
* refactor: renamed existing styleModifier to additionalClasses to even also skip that wording of the functionality from our sample files * refactor: renamed existing styleModifier to additionalClasses to even also skip that wording of the functionality from our sample files * docs: enforced the meaning of this functionality * refactor: renamed existing styleModifier to additionalClasses to even also skip that wording of the functionality from our sample files * refactor: renamed existing styleModifier to additionalClasses to even also skip that wording of the functionality from our sample files * refactor: removed remaining styleModifier parts Co-authored-by: Josef Bredreck <13408112+JosefBredereck@users.noreply.github.com>
1 parent 732b4c8 commit 454292e

File tree

75 files changed

+148
-953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+148
-953
lines changed

packages/core/src/lib/expandPartials.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
const logger = require('./log');
44
const ph = require('./parameter_hunter');
5-
const smh = require('./style_modifier_hunter');
65
const jsonCopy = require('./json_copy');
76
const getPartial = require('./get');
87

98
const parameter_hunter = new ph();
10-
const style_modifier_hunter = new smh();
119

1210
module.exports = function (currentPattern, patternlab) {
1311
const processRecursive = require('./processRecursive');
@@ -47,18 +45,6 @@ module.exports = function (currentPattern, patternlab) {
4745
`partial pattern ${partial}`
4846
);
4947

50-
//if partial has style modifier data, replace the styleModifier value
51-
if (
52-
currentPattern.stylePartials &&
53-
currentPattern.stylePartials.length > 0
54-
) {
55-
style_modifier_hunter.consume_style_modifier(
56-
cleanPartialPattern,
57-
foundPartial,
58-
patternlab
59-
);
60-
}
61-
6248
//this is what we came here for
6349
logger.debug(
6450
`within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate`

packages/core/src/lib/loadPattern.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ module.exports = function (relPath, patternlab) {
132132

133133
currentPattern.template = fs.readFileSync(templatePath, 'utf8');
134134

135-
//find any stylemodifiers that may be in the current pattern
136-
currentPattern.stylePartials =
137-
currentPattern.findPartialsWithStyleModifiers();
138-
139135
//find any pattern parameters that may be in the current pattern
140136
currentPattern.parameteredPartials =
141137
currentPattern.findPartialsWithPatternParameters();

packages/core/src/lib/object_factory.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ Pattern.prototype = {
265265
return this.engine.findPartials(this);
266266
},
267267

268-
findPartialsWithStyleModifiers: function () {
269-
return this.engine.findPartialsWithStyleModifiers(this);
270-
},
271-
272268
findPartialsWithPatternParameters: function () {
273269
return this.engine.findPartialsWithPatternParameters(this);
274270
},

packages/core/src/lib/parameter_hunter.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use strict';
22

3-
const smh = require('./style_modifier_hunter');
4-
const style_modifier_hunter = new smh();
5-
63
const getPartial = require('./get');
74
const logger = require('./log');
85
const parseLink = require('./parseLink');
@@ -313,15 +310,6 @@ const parameter_hunter = function () {
313310
}
314311
}
315312

316-
//if partial has style modifier data, replace the styleModifier value
317-
if (pattern.stylePartials && pattern.stylePartials.length > 0) {
318-
style_modifier_hunter.consume_style_modifier(
319-
partialPattern,
320-
pMatch,
321-
patternlab
322-
);
323-
}
324-
325313
// set pattern.extendedTemplate pMatch with replacedPartial
326314
pattern.extendedTemplate = pattern.extendedTemplate.replace(
327315
pMatch,

packages/core/src/lib/processIterative.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ module.exports = function (pattern, patternlab) {
1111
return pph
1212
.find_pseudopatterns(pattern, patternlab)
1313
.then(() => {
14-
//find any stylemodifiers that may be in the current pattern
15-
pattern.stylePartials = pattern.findPartialsWithStyleModifiers();
16-
1714
//find any pattern parameters that may be in the current pattern
1815
pattern.parameteredPartials = pattern.findPartialsWithPatternParameters();
1916
return Promise.resolve(pattern);

packages/core/src/lib/pseudopattern_hunter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function (
8686
extendedTemplate: currentPattern.extendedTemplate,
8787
isPseudoPattern: true,
8888
basePattern: currentPattern,
89-
stylePartials: currentPattern.stylePartials,
9089
parameteredPartials: currentPattern.parameteredPartials,
9190

9291
// Only regular patterns are discovered during iterative walks

packages/core/src/lib/style_modifier_hunter.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/core/test/engine_handlebars_tests.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,6 @@ tap.test(
248248
}
249249
);
250250

251-
tap.test(
252-
'find_pattern_partials finds simple partials with style modifiers',
253-
function (test) {
254-
testFindPartials(test, ['{{> molecules-single-comment:foo }}']);
255-
}
256-
);
257-
258251
tap.test(
259252
'find_pattern_partials finds partials with handlebars parameters',
260253
function (test) {

packages/core/test/engine_mustache_tests.js

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,6 @@ function testFindPartials(test, partialTests) {
7171
test.end();
7272
}
7373

74-
function testFindPartialsWithStyleModifiers(test, partialTests) {
75-
test.plan(partialTests.length + 1);
76-
77-
// setup current pattern from what we would have during execution
78-
// docs on partial syntax are here:
79-
// https://patternlab.io/docs/including-patterns/
80-
var currentPattern = Pattern.create(
81-
'molecules/testing/test-mol.mustache', // relative path now
82-
null, // data
83-
{
84-
template: partialTests.join(eol),
85-
}
86-
);
87-
88-
// act
89-
var results = currentPattern.findPartialsWithStyleModifiers();
90-
91-
// assert
92-
test.equal(results.length, partialTests.length);
93-
partialTests.forEach(function (testString, index) {
94-
test.equal(results[index], testString);
95-
});
96-
97-
test.end();
98-
}
99-
10074
function testFindPartialsWithPatternParameters(test, partialTests) {
10175
test.plan(partialTests.length + 1);
10276

@@ -160,63 +134,13 @@ tap.test(
160134
}
161135
);
162136

163-
tap.test(
164-
'find_pattern_partials finds simple partials with style modifiers',
165-
function (test) {
166-
testFindPartials(test, [
167-
'{{> molecules-single-comment:foo }}',
168-
'{{> molecules-single-comment:foo|bar }}',
169-
]);
170-
}
171-
);
172-
173137
tap.test('find_pattern_partials finds mixed partials', function (test) {
174138
testFindPartials(test, [
175139
'{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}',
176140
'{{> molecules-single-comment:foo|bar(description: true) }}',
177141
]);
178142
});
179143

180-
tap.test(
181-
'find_pattern_partials finds one simple partial with styleModifier',
182-
function (test) {
183-
testFindPartialsWithStyleModifiers(test, [
184-
'{{> molecules-comment-header:test}}',
185-
]);
186-
}
187-
);
188-
189-
tap.test(
190-
'find_pattern_partials finds partial with many styleModifiers',
191-
function (test) {
192-
testFindPartialsWithStyleModifiers(test, [
193-
'{{> molecules-comment-header:test|test2|test3}}',
194-
]);
195-
}
196-
);
197-
198-
tap.test(
199-
'find_pattern_partials finds partials with differing styleModifiers',
200-
function (test) {
201-
testFindPartialsWithStyleModifiers(test, [
202-
'{{> molecules-comment-header:test|test2|test3}}',
203-
'{{> molecules-comment-header:foo-1}}',
204-
'{{> molecules-comment-header:bar_1}}',
205-
]);
206-
}
207-
);
208-
209-
tap.test(
210-
'find_pattern_partials finds partials with styleModifiers when parameters present',
211-
function (test) {
212-
testFindPartialsWithStyleModifiers(test, [
213-
'{{> molecules-comment-header:test|test2|test3(description: true)}}',
214-
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
215-
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}",
216-
]);
217-
}
218-
);
219-
220144
tap.test(
221145
'find_pattern_partials_with_parameters finds one simple partial with parameters',
222146
function (test) {
@@ -240,14 +164,3 @@ tap.test(
240164
]);
241165
}
242166
);
243-
244-
tap.test(
245-
'find_pattern_partials finds partials with parameters when styleModifiers present',
246-
function (test) {
247-
testFindPartialsWithPatternParameters(test, [
248-
'{{> molecules-comment-header:test|test2|test3(description: true)}}',
249-
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
250-
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}",
251-
]);
252-
}
253-
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div class="{{styleModifier}}">
1+
<div class="{{ additionalClasses }}">
22
{{> test-link }}
33
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{> test-paramMiddle(styleModifier: "foo") }}
1+
{{> test-paramMiddle(additionalClasses: "foo") }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<span class="test_base {{styleModifier}}">
1+
<span class="test_base {{ additionalClasses }}">
22
{{message}}
33
</span>

packages/core/test/index_tests.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -253,34 +253,6 @@ tap.test('buildPatterns suite', (test) => {
253253
}
254254
);
255255

256-
tap.test(
257-
'correctly ignores bookended partials without a style modifier when the same partial has a style modifier between',
258-
(test) => {
259-
var pattern = get('test-bookend-listitem', patternlab);
260-
test.equal(
261-
util.sanitized(pattern.extendedTemplate),
262-
util.sanitized(`<div class="test_group">
263-
{{#listItems-two}}
264-
<span class="test_base {{styleModifier}}">
265-
{{message}}
266-
</span>
267-
268-
<span class="test_base test_1">
269-
{{message}}
270-
</span>
271-
272-
<span class="test_base {{styleModifier}}">
273-
{{message}}
274-
</span>
275-
276-
{{/listItems-two}}
277-
</div>
278-
`)
279-
);
280-
test.end();
281-
}
282-
);
283-
284256
tap.test(
285257
'listItems keys (`one` through `twelve`) can be used more than once per pattern',
286258
(test) => {

0 commit comments

Comments
 (0)