diff --git a/CHANGELOG b/CHANGELOG index c2b2fea19..8ad1f0731 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. +PL-node-v1.1.3 +- FIX: Added pattern type view all pages to the navigation, which users view all 'Atoms/Molecules/Organisms' etc. +- THX: Thanks to @gael-boyenval for originally pointing out the omission. + PL-node-v1.1.2 - FIX: Greatly improved the browsersync configuration, so that it only fires on the iframe, preventing users from losing their scroll position. Also lightened up the styling and made it less obtrusive. - THX: Thanks to @geoffp for taking the lead on this issue. diff --git a/README.md b/README.md index 97b7fed55..156abd8ac 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,11 @@ The Node version of [Pattern Lab](http://patternlab.io/) is, at its core, a stat This repository contains the vanilla builder logic, grunt and gulp configurations, and some sample template/css/data to illustrate the power and flexibility of the tool. +###### Core Team + +* [@bmuenzenmeyer](https://github.com/bmuenzenmeyer) - Lead Maintainer +* [@geoffp](https://github.com/geoffp) - Core Contributor + ### Prerequisites Make sure Node and npm are installed. A great guide can be found here: [https://docs.npmjs.com/getting-started/installing-node](https://docs.npmjs.com/getting-started/installing-node) diff --git a/builder/lineage_hunter.js b/builder/lineage_hunter.js index 8a8616006..7325a5fde 100644 --- a/builder/lineage_hunter.js +++ b/builder/lineage_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/list_item_hunter.js b/builder/list_item_hunter.js index 7e0bc8217..93aa57890 100644 --- a/builder/list_item_hunter.js +++ b/builder/list_item_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/media_hunter.js b/builder/media_hunter.js index b532c91bb..3ee48f4fe 100644 --- a/builder/media_hunter.js +++ b/builder/media_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/object_factory.js b/builder/object_factory.js index bf1770855..5526bdc18 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index 71daf51c5..a3f574951 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. @@ -40,11 +40,11 @@ var rightParen = pMatch.indexOf(')'); var paramString = '{' + pMatch.substring(leftParen + 1, rightParen) + '}'; //if param keys are wrapped in single quotes, replace with double quotes. - var paramStringWellFormed = paramString.replace(/(')([^']+)(')(\s*\:)/gm, '"$2"$4'); + var paramStringWellFormed = paramString.replace(/(')([^']+)(')(\s*\:)/g, '"$2"$4'); //if params keys are not wrapped in any quotes, wrap in double quotes. - var paramStringWellFormed = paramStringWellFormed.replace(/([\{|,]\s*)([^\:\s]+)(\s*\:)/gm, '$1"$2"$3'); + var paramStringWellFormed = paramStringWellFormed.replace(/([\{|,]\s*)([^\s"'\:]+)(\s*\:)/g, '$1"$2"$3'); //if param values are wrapped in single quotes, replace with double quotes. - var paramStringWellFormed = paramStringWellFormed.replace(/(\:\s*)(')([^']+)(')/gm, '$1"$3"'); + var paramStringWellFormed = paramStringWellFormed.replace(/(\:\s*)(')([^']+)(')/g, '$1"$3"'); var paramData = {}; var globalData = {}; diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 888fd09e2..d200f059d 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pattern_exporter.js b/builder/pattern_exporter.js index 3a70bea98..3d04658d3 100644 --- a/builder/pattern_exporter.js +++ b/builder/pattern_exporter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab.js b/builder/patternlab.js index 2404d6c9a..aae791f23 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. @@ -207,7 +207,8 @@ var patternlab_engine = function (config) { //build the viewall pages var prevSubdir = '', - i; + prevGroup = '', + i; for (i = 0; i < patternlab.patterns.length; i++) { // skip underscore-prefixed files @@ -220,6 +221,35 @@ var patternlab_engine = function (config) { var pattern = patternlab.patterns[i]; + //create the view all for the section + // check if the current section is different from the previous one + if (pattern.patternGroup != prevGroup){ + prevGroup = pattern.patternGroup; + + var viewAllPatterns = [], + patternPartial = "viewall-" + pattern.patternGroup, + j; + + for (j = 0; j < patternlab.patterns.length; j++) { + if (patternlab.patterns[j].patternGroup === pattern.patternGroup) { + //again, skip any sibling patterns to the current one that may have underscores + if(isPatternExcluded(patternlab.patterns[j])){ + if(patternlab.config.debug){ + console.log('Omitting ' + patternlab.patterns[j].key + " from view all sibling rendering."); + } + continue; + } + + viewAllPatterns.push(patternlab.patterns[j]); + } + } + + var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'viewall.mustache'), 'utf8'); + var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial}); + fs.outputFileSync(paths.public.patterns + pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + '/index.html', viewAllHtml); + } + + //create the view all for the subsection // check if the current sub section is different from the previous one if (pattern.subdir !== prevSubdir) { prevSubdir = pattern.subdir; @@ -318,6 +348,14 @@ var patternlab_engine = function (config) { //add to patternPaths addToPatternPaths(bucketName, pattern); + //add the navViewAllItem + var navViewAllItem = new of.oNavSubItem("View All"); + navViewAllItem.patternPath = pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + "/index.html"; + navViewAllItem.patternPartial = "viewall-" + pattern.patternGroup; + + bucket.patternItems.push(navViewAllItem); + patternlab.viewAllPaths[bucketName]['viewall'] = pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length); + } //add the bucket. @@ -393,14 +431,15 @@ var patternlab_engine = function (config) { } } - //add the navViewAllSubItem - var navViewAllSubItem = new of.oNavSubItem(""); - navViewAllSubItem.patternName = "View All"; - navViewAllSubItem.patternPath = pattern.flatPatternPath + "/index.html"; - navViewAllSubItem.patternPartial = "viewall-" + pattern.patternGroup + "-" + pattern.patternSubGroup; - //check if we are moving to a new sub section in the next loop if (!patternlab.patterns[i + 1] || pattern.patternSubGroup !== patternlab.patterns[i + 1].patternSubGroup) { + + //add the navViewAllSubItem + var navViewAllSubItem = new of.oNavSubItem(""); + navViewAllSubItem.patternName = "View All"; + navViewAllSubItem.patternPath = pattern.flatPatternPath + "/index.html"; + navViewAllSubItem.patternPartial = "viewall-" + pattern.patternGroup + "-" + pattern.patternSubGroup; + navItem.navSubItems.push(navViewAllSubItem); navItem.navSubItemsIndex.push("View All"); } diff --git a/builder/patternlab_grunt.js b/builder/patternlab_grunt.js index 7f22c987f..93b50b1e7 100644 --- a/builder/patternlab_grunt.js +++ b/builder/patternlab_grunt.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js index a0125e657..e036b1bb5 100644 --- a/builder/patternlab_gulp.js +++ b/builder/patternlab_gulp.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index f2765aaa5..77773040e 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/style_modifier_hunter.js b/builder/style_modifier_hunter.js index 11cce9d27..a19fbf081 100644 --- a/builder/style_modifier_hunter.js +++ b/builder/style_modifier_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.2 - 2016 + * patternlab-node - v1.1.3 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/gulpfile.js b/gulpfile.js index a481efccd..fb15e1439 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -77,7 +77,7 @@ gulp.task('cp:img', function(){ // Fonts copy gulp.task('cp:font', function(){ return gulp.src('*', {cwd: path.resolve(paths().source.fonts)}) - .pipe(gulp.dest(path.resolve(paths().public.images))); + .pipe(gulp.dest(path.resolve(paths().public.fonts))); }); // Data copy diff --git a/package.gulp.json b/package.gulp.json index 9130aca63..7bdc7cb2c 100644 --- a/package.gulp.json +++ b/package.gulp.json @@ -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": "1.1.2", + "version": "1.1.3", "main": "./builder/patternlab.js", "dependencies": { "del": "^2.2.0", diff --git a/package.json b/package.json index 47ac92da2..4cfbf8671 100644 --- a/package.json +++ b/package.json @@ -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": "1.1.2", + "version": "1.1.3", "main": "./builder/patternlab.js", "dependencies": { "diveSync": "^0.3.0", diff --git a/test/parameter_hunter_tests.js b/test/parameter_hunter_tests.js index f2ecdc414..069986553 100644 --- a/test/parameter_hunter_tests.js +++ b/test/parameter_hunter_tests.js @@ -1,222 +1,237 @@ (function () { - "use strict"; - - var ph = require('../builder/parameter_hunter'); - - exports['parameter_hunter'] = { - 'pattern hunter finds and extends templates' : function(test){ - - //setup current pattern from what we would have during execution - var currentPattern = { - "fileName": "01-sticky-comment", - "subdir": "02-organisms/02-comments", - "name": "02-organisms-02-comments-01-sticky-comment", - "patternName": "sticky-comment", - "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", - "patternGroup": "organisms", - "patternSubGroup": "comments", - "flatPatternPath": "02-organisms-02-comments", - "key": "organisms-sticky-comment", - "template": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "extendedTemplate": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "parameteredPartials": [ - "{{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", - "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" - ] - }; - var patternlab = { - patterns: [ - { - "fileName": "02-single-comment", - "subdir": "01-molecules/06-components", - "name": "01-molecules-06-components-02-single-comment", - "patternName": "single-comment", - "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", - "patternGroup": "molecules", - "patternSubGroup": "components", - "flatPatternPath": "01-molecules-06-components", - "key": "molecules-single-comment", - "template": "

{{description}}

", - "extendedTemplate": "

{{description}}

" - } - ], - config: { - debug: false - }, - data: { - description: 'Not a quote from a smart man' - }, - partials: {}, - }; - - var parameter_hunter = new ph(); + "use strict"; + + var ph = require('../builder/parameter_hunter'); + + //setup current pattern from what we would have during execution + function currentPatternClosure() { + return { + "fileName": "01-sticky-comment", + "subdir": "02-organisms/02-comments", + "name": "02-organisms-02-comments-01-sticky-comment", + "patternName": "sticky-comment", + "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", + "patternGroup": "organisms", + "patternSubGroup": "comments", + "flatPatternPath": "02-organisms-02-comments", + "key": "organisms-sticky-comment", + "template": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", + "extendedTemplate": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", + "parameteredPartials": [ + "{{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", + "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" + ] + }; + } + + function patternlabClosure() { + return { + patterns: [ + { + "fileName": "02-single-comment", + "subdir": "01-molecules/06-components", + "name": "01-molecules-06-components-02-single-comment", + "patternName": "single-comment", + "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", + "patternGroup": "molecules", + "patternSubGroup": "components", + "flatPatternPath": "01-molecules-06-components", + "key": "molecules-single-comment", + "template": "

{{description}}

", + "extendedTemplate": "

{{description}}

" + } + ], + config: { + debug: false + }, + data: { + description: 'Not a quote from a smart man' + }, + partials: {} + } + }; + + exports['parameter_hunter'] = { + 'parameter hunter finds and extends templates' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); parameter_hunter.find_parameters(currentPattern, patternlab); test.equals(currentPattern.extendedTemplate, '

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

'); - test.done(); - }, - - 'pattern hunter finds and extends templates with mixed parameter and global data' : function(test){ - - //setup current pattern from what we would have during execution - var currentPattern = { - "fileName": "01-sticky-comment", - "subdir": "02-organisms/02-comments", - "name": "02-organisms-02-comments-01-sticky-comment", - "patternName": "sticky-comment", - "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", - "patternGroup": "organisms", - "patternSubGroup": "comments", - "flatPatternPath": "02-organisms-02-comments", - "key": "organisms-sticky-comment", - "template": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "extendedTemplate": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "parameteredPartials": [ - "{{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", - "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" - ] - }; - var patternlab = { - partials: {}, - patterns: [ - { - "fileName": "02-single-comment", - "subdir": "01-molecules/06-components", - "name": "01-molecules-06-components-02-single-comment", - "patternName": "single-comment", - "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", - "patternGroup": "molecules", - "patternSubGroup": "components", - "flatPatternPath": "01-molecules-06-components", - "key": "molecules-single-comment", - "template": "

{{foo}}

{{description}}

", - "extendedTemplate": "

{{foo}}

{{description}}

" - } - ], - config: { - debug: false - }, - data: { - foo: 'Bar', - description: 'Baz' - } - }; + test.done(); + }, + 'parameter hunter finds and extends templates with mixed parameter and global data' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); var parameter_hunter = new ph(); + patternlab.patterns[0].template = "

{{foo}}

{{description}}

"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + patternlab.data.foo = 'Bar'; + patternlab.data.description = 'Baz'; + parameter_hunter.find_parameters(currentPattern, patternlab); test.equals(currentPattern.extendedTemplate, '

Bar

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

'); test.done(); }, - 'pattern hunter finds and extends templates with verbose partials' : function(test){ - - //setup current pattern from what we would have during execution - var currentPattern = { - "fileName": "01-sticky-comment", - "subdir": "02-organisms/02-comments", - "name": "02-organisms-02-comments-01-sticky-comment", - "patternName": "sticky-comment", - "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", - "patternGroup": "organisms", - "patternSubGroup": "comments", - "flatPatternPath": "02-organisms-02-comments", - "key": "organisms-sticky-comment", - "template": "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "extendedTemplate": "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "parameteredPartials": [ - "{{> 01-molecules/06-components/02-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", - "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" - ] - }; - var patternlab = { - partials: {}, - patterns: [ - { - "fileName": "02-single-comment", - "subdir": "01-molecules/06-components", - "name": "01-molecules-06-components-02-single-comment", - "patternName": "single-comment", - "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", - "patternGroup": "molecules", - "patternSubGroup": "components", - "flatPatternPath": "01-molecules-06-components", - "key": "molecules-single-comment", - "template": "

{{description}}

", - "extendedTemplate": "

{{description}}

" - } - ], - config: { - debug: false - }, - data: { - description: 'Not a quote from a smart man' - } - }; + 'parameter hunter finds and extends templates with verbose partials' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; + currentPattern.parameteredPartials[1] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

'); + test.done(); + }, + + 'parameter hunter finds and extends templates with fully-pathed partials' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); var parameter_hunter = new ph(); + currentPattern.template = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; + currentPattern.parameteredPartials[1] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); test.equals(currentPattern.extendedTemplate, '

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

'); test.done(); }, - 'pattern hunter finds and extends templates with fully-pathed partials' : function(test){ - - //setup current pattern from what we would have during execution - var currentPattern = { - "fileName": "01-sticky-comment", - "subdir": "02-organisms/02-comments", - "name": "02-organisms-02-comments-01-sticky-comment", - "patternName": "sticky-comment", - "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", - "patternGroup": "organisms", - "patternSubGroup": "comments", - "flatPatternPath": "02-organisms-02-comments", - "key": "organisms-sticky-comment", - "template": "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "extendedTemplate": "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "parameteredPartials": [ - "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", - "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" - ] - }; - var patternlab = { - partials: {}, - patterns: [ - { - "fileName": "02-single-comment", - "subdir": "01-molecules/06-components", - "name": "01-molecules-06-components-02-single-comment", - "patternName": "single-comment", - "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", - "patternGroup": "molecules", - "patternSubGroup": "components", - "flatPatternPath": "01-molecules-06-components", - "key": "molecules-single-comment", - "template": "

{{description}}

", - "extendedTemplate": "

{{description}}

" - } - ], - config: { - debug: false - }, - data: { - description: 'Not a quote from a smart man' - } - }; + //previous tests were for unquoted parameter keys and single-quoted values. + //test other quoting options. + 'parameter hunter parses parameters with unquoted keys and unquoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment(description: true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + 'parameter hunter parses parameters with unquoted keys and double-quoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(description: \"true\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, '

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

'); + test.equals(currentPattern.extendedTemplate, '

true

'); test.done(); - } + }, + + 'parameter hunter parses parameters with single-quoted keys and unquoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment('description': true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + 'parameter hunter parses parameters with single-quoted keys and single-quoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment('description': 'true') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + + 'parameter hunter parses parameters with single-quoted keys and double-quoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment('description': \"true\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + + 'parameter hunter parses parameters with double-unquoted keys and unquoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment(\"description\": true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + + 'parameter hunter parses parameters with double-quoted keys and single-quoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment(\"description\": 'true') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + }, + + 'parameter hunter parses parameters with double-quoted keys and double-quoted values' : function(test){ + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); + + currentPattern.template = "{{> molecules-single-comment(\"description\": \"true\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; + + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, '

true

'); + + test.done(); + } }; }());