Skip to content
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

refactor patternName per styleguidekit-mustache-default key mismatch #346

Merged
merged 1 commit into from
Jun 3, 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
2 changes: 1 addition & 1 deletion core/lib/list_item_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var list_item_hunter = function () {
var repeatedBlockHtml = '';
for (var i = 0; i < items.indexOf(loopNumberString); i++) {
if (patternlab.config.debug) {
console.log('list item(s) in pattern', pattern.patternName, 'adding', patternBlock, 'to repeatedBlockTemplate');
console.log('list item(s) in pattern', pattern.patternPartial, 'adding', patternBlock, 'to repeatedBlockTemplate');
}
repeatedBlockTemplate.push(patternBlock);
}
Expand Down
6 changes: 3 additions & 3 deletions core/lib/object_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ var Pattern = function (relPath, data) {
this.jsonFileData = data || {};

// strip leading "00-" from the file name and flip tildes to dashes
this.patternName = this.fileName.replace(/^\d*\-/, '').replace('~', '-'); // 'colors'
this.patternBaseName = this.fileName.replace(/^\d*\-/, '').replace('~', '-'); // 'colors'

// Fancy name. No idea how this works. 'Colors'
this.patternDisplayName = this.patternName.split('-').reduce(function (val, working) {
this.patternName = this.patternBaseName.split('-').reduce(function (val, working) {
return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1);
}, '').trim(); //this is the display name for the ui. strip numeric + hyphen prefixes

Expand All @@ -44,7 +44,7 @@ var Pattern = function (relPath, data) {

// The canonical "key" by which this pattern is known. This is the callable
// name of the pattern. UPDATE: this.key is now known as this.patternPartial
this.patternPartial = this.patternGroup + '-' + this.patternName;
this.patternPartial = this.patternGroup + '-' + this.patternBaseName;

this.template = '';
this.patternPartialCode = '';
Expand Down
2 changes: 1 addition & 1 deletion core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var pattern_assembler = function () {
function addPattern(pattern, patternlab) {

//add the link to the global object
patternlab.data.link[pattern.patternGroup + '-' + pattern.patternName] = '/patterns/' + pattern.patternLink;
patternlab.data.link[pattern.patternGroup + '-' + pattern.patternBaseName] = '/patterns/' + pattern.patternLink;

//only push to array if the array doesn't contain this pattern
var isNew = true;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ var patternlab_engine = function (config) {
lineageR: pattern.patternLineagesR,
patternLineageEExists: pattern.patternLineageExists || pattern.patternLineageRExists,
patternDesc: pattern.patternDescExists ? pattern.patternDesc : '',
patternBreadcrumb: 'TODO',
patternBreadcrumb: pattern.patternGroup,
patternExtension: pattern.fileExtension,
patternName: pattern.patternName,
patternPartial: pattern.patternPartial,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/ui_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var eol = require('os').EOL;

function addToPatternPaths(patternlab, patternTypeName, pattern) {
//this is messy, could use a refactor.
patternlab.patternPaths[patternTypeName][pattern.patternName] = pattern.subdir.replace(/\\/g, '/') + "/" + pattern.fileName;
patternlab.patternPaths[patternTypeName][pattern.patternBaseName] = pattern.subdir.replace(/\\/g, '/') + "/" + pattern.fileName;
}

//todo: refactor this as a method on the pattern object itself once we merge dev with pattern-engines branch
Expand Down
22 changes: 11 additions & 11 deletions test/lineage_hunter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<a href=\"/\"><img src=\"../../images/logo.png\" class=\"logo\" alt=\"Logo Alt Text\" /></a>",
"patternPartialCode": "<a href=\"/\"><img src=\"../../images/logo.png\" class=\"logo\" alt=\"Logo Alt Text\" /></a>",
"patternName": "logo",
"patternBaseName": "logo",
"patternLink": "00-atoms-03-images-00-logo/00-atoms-03-images-00-logo.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\03-images",
Expand All @@ -80,7 +80,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<nav id=\"nav\" class=\"nav\">\r\n\t<ul>\r\n\t\t<li><a href=\"#\">Home</a></li>\r\n\t\t<li><a href=\"#\">About</a></li>\r\n\t\t<li><a href=\"#\">Blog</a></li>\r\n\t\t<li><a href=\"#\">Contact</a></li>\r\n\t</ul>\r\n</nav><!--end .nav-->\r\n",
"patternPartialCode": "<nav id=\"nav\" class=\"nav\">\r\n\t<ul>\r\n\t\t<li><a href=\"#\">Home</a></li>\r\n\t\t<li><a href=\"#\">About</a></li>\r\n\t\t<li><a href=\"#\">Blog</a></li>\r\n\t\t<li><a href=\"#\">Contact</a></li>\r\n\t</ul>\r\n</nav><!--end .nav-->\r\n",
"patternName": "primary-nav",
"patternBaseName": "primary-nav",
"patternLink": "01-molecules-05-navigation-00-primary-nav/01-molecules-05-navigation-00-primary-nav.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\05-navigation",
Expand All @@ -99,7 +99,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<form action=\"#\" method=\"post\" class=\"inline-form search-form\"> \r\n <fieldset>\r\n\t <legend class=\"is-vishidden\">Search</legend>\r\n\t <label for=\"search-field\" class=\"is-vishidden\">Search</label>\r\n\t <input type=\"search\" placeholder=\"Search\" id=\"search-field\" class=\"search-field\" />\r\n\t <button class=\"search-submit\">\r\n\t \t<span class=\"icon-search\" aria-hidden=\"true\"></span>\r\n\t \t<span class=\"is-vishidden\">Search</span>\r\n\t </button>\r\n </fieldset>\r\n</form>",
"patternPartialCode": "<form action=\"#\" method=\"post\" class=\"inline-form search-form\"> \r\n <fieldset>\r\n\t <legend class=\"is-vishidden\">Search</legend>\r\n\t <label for=\"search-field\" class=\"is-vishidden\">Search</label>\r\n\t <input type=\"search\" placeholder=\"Search\" id=\"search-field\" class=\"search-field\" />\r\n\t <button class=\"search-submit\">\r\n\t \t<span class=\"icon-search\" aria-hidden=\"true\"></span>\r\n\t \t<span class=\"is-vishidden\">Search</span>\r\n\t </button>\r\n </fieldset>\r\n</form>",
"patternName": "search",
"patternBaseName": "search",
"patternLink": "01-molecules-04-forms-00-search/01-molecules-04-forms-00-search.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\04-forms",
Expand Down Expand Up @@ -303,7 +303,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<h1> {{message}} </h1>",
"extendedTemplate": "<h1> {{message}} </h1>",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
Expand Down Expand Up @@ -338,7 +338,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "{{> atoms-error:foo }}",
"extendedTemplate": "{{> atoms-error:foo }}",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
Expand All @@ -359,7 +359,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<h1> {{message}} </h1>",
"extendedTemplate": "<h1> {{message}} </h1>",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
Expand Down Expand Up @@ -392,7 +392,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "{{> atoms-error:foo }}",
"extendedTemplate": "{{>atoms-error:foo}}",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
Expand All @@ -413,7 +413,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<h1> {{message}} </h1>",
"extendedTemlpate": "<h1> {{message}} </h1>",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
Expand Down Expand Up @@ -446,7 +446,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "{{> atoms-e:foo }}",
"extendedTemplate": "{{>atoms-e:foo}}",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html",
"patternGroup": "molecules",
"patternSubGroup": "molecules\\01-toast",
Expand All @@ -467,7 +467,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<h1> {{message}} </h1>",
"extendedTemplate": "<h1> {{message}} </h1>",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
Expand Down Expand Up @@ -507,7 +507,7 @@ exports['lineage hunter '] = {
"data": null,
"template": "<h1> {{message}} </h1>",
"extendedTemplate": "<h1> {{message}} </h1>",
"patternName": "error",
"patternBaseName": "error",
"patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html",
"patternGroup": "atoms",
"patternSubGroup": "atoms\\05-alerts",
Expand Down
18 changes: 6 additions & 12 deletions test/object_factory_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
test.equals(p.fileName, '00-colors');
test.equals(p.fileExtension, '.mustache');
test.equals(p.jsonFileData.d, 123);
test.equals(p.patternName, 'colors');
test.equals(p.patternDisplayName, 'Colors');
test.equals(p.patternBaseName, 'colors');
test.equals(p.patternName, 'Colors');
test.equals(p.patternLink, '00-atoms-00-global-00-colors/00-atoms-00-global-00-colors.html');
test.equals(p.patternGroup, 'atoms');
test.equals(p.patternSubGroup, 'global');
Expand All @@ -36,8 +36,8 @@
test.equals(p.fileName, '00-colors');
test.equals(p.fileExtension, '.mustache');
test.equals(p.jsonFileData.d, 123);
test.equals(p.patternName, 'colors');
test.equals(p.patternDisplayName, 'Colors');
test.equals(p.patternBaseName, 'colors');
test.equals(p.patternName, 'Colors');
test.equals(p.patternLink, '00-atoms-00-colors/00-atoms-00-colors.html');
test.equals(p.patternGroup, 'atoms');
test.equals(p.flatPatternPath, '00-atoms');
Expand All @@ -51,14 +51,8 @@
},
'test Pattern capitalizes patternDisplayName correctly' : function(test){
var p = new Pattern('00-atoms/00-global/00-colors-alt.mustache', { d: 123});
test.equals(p.patternName, 'colors-alt');
test.equals(p.patternDisplayName, 'Colors Alt');
test.done();
},
'test Pattern removes pattern paramter from key correctly' : function(test){
var p = new Pattern('00-atoms/00-global/00-colors-alt.mustache', { d: 123});
test.equals(p.patternName, 'colors-alt');
test.equals(p.patternDisplayName, 'Colors Alt');
test.equals(p.patternBaseName, 'colors-alt');
test.equals(p.patternName, 'Colors Alt');
test.done();
}
};
Expand Down
4 changes: 2 additions & 2 deletions test/parameter_hunter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"fileName": "01-sticky-comment",
"subdir": "02-organisms/02-comments",
"name": "02-organisms-02-comments-01-sticky-comment",
"patternName": "sticky-comment",
"patternBaseName": "sticky-comment",
"patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html",
"patternGroup": "organisms",
"patternSubGroup": "comments",
Expand All @@ -31,7 +31,7 @@
"fileName": "02-single-comment",
"subdir": "01-molecules/06-components",
"name": "01-molecules-06-components-02-single-comment",
"patternName": "single-comment",
"patternBaseName": "single-comment",
"patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html",
"patternGroup": "molecules",
"patternSubGroup": "components",
Expand Down