diff --git a/packages/core/src/lib/expandPartials.js b/packages/core/src/lib/expandPartials.js index f153ff467..d9f7fad8e 100644 --- a/packages/core/src/lib/expandPartials.js +++ b/packages/core/src/lib/expandPartials.js @@ -2,12 +2,10 @@ const logger = require('./log'); const ph = require('./parameter_hunter'); -const smh = require('./style_modifier_hunter'); const jsonCopy = require('./json_copy'); const getPartial = require('./get'); const parameter_hunter = new ph(); -const style_modifier_hunter = new smh(); module.exports = function (currentPattern, patternlab) { const processRecursive = require('./processRecursive'); @@ -47,18 +45,6 @@ module.exports = function (currentPattern, patternlab) { `partial pattern ${partial}` ); - //if partial has style modifier data, replace the styleModifier value - if ( - currentPattern.stylePartials && - currentPattern.stylePartials.length > 0 - ) { - style_modifier_hunter.consume_style_modifier( - cleanPartialPattern, - foundPartial, - patternlab - ); - } - //this is what we came here for logger.debug( `within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate` diff --git a/packages/core/src/lib/loadPattern.js b/packages/core/src/lib/loadPattern.js index 9d6b22519..b5990fecf 100644 --- a/packages/core/src/lib/loadPattern.js +++ b/packages/core/src/lib/loadPattern.js @@ -132,10 +132,6 @@ module.exports = function (relPath, patternlab) { currentPattern.template = fs.readFileSync(templatePath, 'utf8'); - //find any stylemodifiers that may be in the current pattern - currentPattern.stylePartials = - currentPattern.findPartialsWithStyleModifiers(); - //find any pattern parameters that may be in the current pattern currentPattern.parameteredPartials = currentPattern.findPartialsWithPatternParameters(); diff --git a/packages/core/src/lib/object_factory.js b/packages/core/src/lib/object_factory.js index 704474881..318b4cd25 100644 --- a/packages/core/src/lib/object_factory.js +++ b/packages/core/src/lib/object_factory.js @@ -265,10 +265,6 @@ Pattern.prototype = { return this.engine.findPartials(this); }, - findPartialsWithStyleModifiers: function () { - return this.engine.findPartialsWithStyleModifiers(this); - }, - findPartialsWithPatternParameters: function () { return this.engine.findPartialsWithPatternParameters(this); }, diff --git a/packages/core/src/lib/parameter_hunter.js b/packages/core/src/lib/parameter_hunter.js index 3a6d018e5..01a260ffc 100644 --- a/packages/core/src/lib/parameter_hunter.js +++ b/packages/core/src/lib/parameter_hunter.js @@ -1,8 +1,5 @@ 'use strict'; -const smh = require('./style_modifier_hunter'); -const style_modifier_hunter = new smh(); - const getPartial = require('./get'); const logger = require('./log'); const parseLink = require('./parseLink'); @@ -313,15 +310,6 @@ const parameter_hunter = function () { } } - //if partial has style modifier data, replace the styleModifier value - if (pattern.stylePartials && pattern.stylePartials.length > 0) { - style_modifier_hunter.consume_style_modifier( - partialPattern, - pMatch, - patternlab - ); - } - // set pattern.extendedTemplate pMatch with replacedPartial pattern.extendedTemplate = pattern.extendedTemplate.replace( pMatch, diff --git a/packages/core/src/lib/processIterative.js b/packages/core/src/lib/processIterative.js index e2433b1c8..8f57f7dff 100644 --- a/packages/core/src/lib/processIterative.js +++ b/packages/core/src/lib/processIterative.js @@ -11,9 +11,6 @@ module.exports = function (pattern, patternlab) { return pph .find_pseudopatterns(pattern, patternlab) .then(() => { - //find any stylemodifiers that may be in the current pattern - pattern.stylePartials = pattern.findPartialsWithStyleModifiers(); - //find any pattern parameters that may be in the current pattern pattern.parameteredPartials = pattern.findPartialsWithPatternParameters(); return Promise.resolve(pattern); diff --git a/packages/core/src/lib/pseudopattern_hunter.js b/packages/core/src/lib/pseudopattern_hunter.js index 73e703564..28d4f3e1a 100644 --- a/packages/core/src/lib/pseudopattern_hunter.js +++ b/packages/core/src/lib/pseudopattern_hunter.js @@ -86,7 +86,6 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function ( extendedTemplate: currentPattern.extendedTemplate, isPseudoPattern: true, basePattern: currentPattern, - stylePartials: currentPattern.stylePartials, parameteredPartials: currentPattern.parameteredPartials, // Only regular patterns are discovered during iterative walks diff --git a/packages/core/src/lib/style_modifier_hunter.js b/packages/core/src/lib/style_modifier_hunter.js deleted file mode 100644 index bd62c773a..000000000 --- a/packages/core/src/lib/style_modifier_hunter.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const logger = require('./log'); - -const style_modifier_hunter = function () { - /** - * Modifies a patterns partial with any styleModifiers found on the supplied partial - * - * @param pattern {object} the pattern to extend - * @param partial {string} partial containing styleModifiers - * @param patternlab {object} the patternlab instance - */ - function consumestylemodifier(pattern, partial, patternlab) { - //extract the classname from the stylemodifier which comes in the format of :className - let styleModifier = partial.match(/:([\w\-_|])+/g) - ? partial.match(/:([\w\-_|])+/g)[0].slice(1) - : null; - - if (styleModifier) { - //replace the special character pipe | used to separate multiple classes with a space - styleModifier = styleModifier.replace(/\|/g, ' '); - - logger.debug( - `Found partial styleModifier within pattern ${pattern.patternPartial}` - ); - - //replace the stylemodifier placeholder with the class name - pattern.extendedTemplate = pattern.extendedTemplate.replace( - /{{[ ]?styleModifier[ ]?}}/i, - styleModifier - ); - - //update the extendedTemplate in the partials object in case this pattern is consumed later - patternlab.partials[pattern.patternPartial] = pattern.extendedTemplate; - } - } - - return { - consume_style_modifier: function (pattern, partial, patternlab) { - consumestylemodifier(pattern, partial, patternlab); - }, - }; -}; - -module.exports = style_modifier_hunter; diff --git a/packages/core/test/engine_handlebars_tests.js b/packages/core/test/engine_handlebars_tests.js index f842c4357..8e5d3c34e 100644 --- a/packages/core/test/engine_handlebars_tests.js +++ b/packages/core/test/engine_handlebars_tests.js @@ -248,13 +248,6 @@ tap.test( } ); -tap.test( - 'find_pattern_partials finds simple partials with style modifiers', - function (test) { - testFindPartials(test, ['{{> molecules-single-comment:foo }}']); - } -); - tap.test( 'find_pattern_partials finds partials with handlebars parameters', function (test) { diff --git a/packages/core/test/engine_mustache_tests.js b/packages/core/test/engine_mustache_tests.js index 1bfcf8cee..dd5e3fb19 100644 --- a/packages/core/test/engine_mustache_tests.js +++ b/packages/core/test/engine_mustache_tests.js @@ -71,32 +71,6 @@ function testFindPartials(test, partialTests) { test.end(); } -function testFindPartialsWithStyleModifiers(test, partialTests) { - test.plan(partialTests.length + 1); - - // setup current pattern from what we would have during execution - // docs on partial syntax are here: - // https://patternlab.io/docs/including-patterns/ - var currentPattern = Pattern.create( - 'molecules/testing/test-mol.mustache', // relative path now - null, // data - { - template: partialTests.join(eol), - } - ); - - // act - var results = currentPattern.findPartialsWithStyleModifiers(); - - // assert - test.equal(results.length, partialTests.length); - partialTests.forEach(function (testString, index) { - test.equal(results[index], testString); - }); - - test.end(); -} - function testFindPartialsWithPatternParameters(test, partialTests) { test.plan(partialTests.length + 1); @@ -160,16 +134,6 @@ tap.test( } ); -tap.test( - 'find_pattern_partials finds simple partials with style modifiers', - function (test) { - testFindPartials(test, [ - '{{> molecules-single-comment:foo }}', - '{{> molecules-single-comment:foo|bar }}', - ]); - } -); - tap.test('find_pattern_partials finds mixed partials', function (test) { testFindPartials(test, [ '{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}', @@ -177,46 +141,6 @@ tap.test('find_pattern_partials finds mixed partials', function (test) { ]); }); -tap.test( - 'find_pattern_partials finds one simple partial with styleModifier', - function (test) { - testFindPartialsWithStyleModifiers(test, [ - '{{> molecules-comment-header:test}}', - ]); - } -); - -tap.test( - 'find_pattern_partials finds partial with many styleModifiers', - function (test) { - testFindPartialsWithStyleModifiers(test, [ - '{{> molecules-comment-header:test|test2|test3}}', - ]); - } -); - -tap.test( - 'find_pattern_partials finds partials with differing styleModifiers', - function (test) { - testFindPartialsWithStyleModifiers(test, [ - '{{> molecules-comment-header:test|test2|test3}}', - '{{> molecules-comment-header:foo-1}}', - '{{> molecules-comment-header:bar_1}}', - ]); - } -); - -tap.test( - 'find_pattern_partials finds partials with styleModifiers when parameters present', - function (test) { - testFindPartialsWithStyleModifiers(test, [ - '{{> molecules-comment-header:test|test2|test3(description: true)}}', - "{{> molecules-comment-header:foo-1(description: 'foo')}}", - "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}", - ]); - } -); - tap.test( 'find_pattern_partials_with_parameters finds one simple partial with parameters', function (test) { @@ -240,14 +164,3 @@ tap.test( ]); } ); - -tap.test( - 'find_pattern_partials finds partials with parameters when styleModifiers present', - function (test) { - testFindPartialsWithPatternParameters(test, [ - '{{> molecules-comment-header:test|test2|test3(description: true)}}', - "{{> molecules-comment-header:foo-1(description: 'foo')}}", - "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}", - ]); - } -); diff --git a/packages/core/test/files/_patterns/test/paramMiddle.mustache b/packages/core/test/files/_patterns/test/paramMiddle.mustache index 31169fb7e..b69912370 100644 --- a/packages/core/test/files/_patterns/test/paramMiddle.mustache +++ b/packages/core/test/files/_patterns/test/paramMiddle.mustache @@ -1,3 +1,3 @@ -
{{ description }}
-