diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3137b6a2d..be5b0bd4c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ - + diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7746fd362..637f28bce 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 648d89c97..12752d1c8 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -7,12 +7,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: '14' + node-version: '16' - name: Setup the project run: | diff --git a/.nvmrc b/.nvmrc index 8aeef54f8..59ea99ee6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14.21 +16.20 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de8a2a36..52f197a05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,39 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + + +### Features + +* **engine-twig-php:** update @basalt/twig-renderer to v3.0.1 using Twig v3.7.1 ([#1499](https://github.com/pattern-lab/patternlab-node/issues/1499)) ([2e5c9e1](https://github.com/pattern-lab/patternlab-node/commit/2e5c9e1c6a3318ba1cd3765d448c181e4a3a9a27)), closes [#1496](https://github.com/pattern-lab/patternlab-node/issues/1496) [#1496](https://github.com/pattern-lab/patternlab-node/issues/1496) + + + + + +## [6.0.3](https://github.com/pattern-lab/patternlab-node/compare/v6.0.2...v6.0.3) (2023-03-12) + + +### Bug Fixes + +* subitems menu height restricted only for horizontal mode ([#1492](https://github.com/pattern-lab/patternlab-node/issues/1492)) ([e65f294](https://github.com/pattern-lab/patternlab-node/commit/e65f294d9cbf032fd7fd03d9f957500949db5440)) + + + + + +## [6.0.2](https://github.com/pattern-lab/patternlab-node/compare/v6.0.1...v6.0.2) (2023-02-26) + + +### Bug Fixes + +* **starterkit-twig-demo:** pages not rendering pattern-specific data from json ([#1490](https://github.com/pattern-lab/patternlab-node/issues/1490)) ([1c878df](https://github.com/pattern-lab/patternlab-node/commit/1c878dfa35d549f23e199b3e235ff79cb471ac86)), closes [#1486](https://github.com/pattern-lab/patternlab-node/issues/1486) + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) diff --git a/lerna.json b/lerna.json index 82ccc8058..7a57a21cc 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "4.0.0", - "version": "6.0.1", + "version": "6.1.0", "packages": [ "packages/*" ], diff --git a/packages/cli/.nvmrc b/packages/cli/.nvmrc index 8aeef54f8..59ea99ee6 100644 --- a/packages/cli/.nvmrc +++ b/packages/cli/.nvmrc @@ -1 +1 @@ -14.21 +16.20 diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 12ca13960..cadcbeb26 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/cli + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) **Note:** Version bump only for package @pattern-lab/cli diff --git a/packages/cli/package.json b/packages/cli/package.json index 6fe53072e..ddfe4da2e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@pattern-lab/cli", "description": "Command-line interface (CLI) for the @pattern-lab/core.", - "version": "6.0.1", + "version": "6.1.0", "bin": { "patternlab": "bin/patternlab.js" }, @@ -9,7 +9,7 @@ "name": "Patternlab contributors" }, "dependencies": { - "@pattern-lab/core": "^6.0.1", + "@pattern-lab/core": "^6.1.0", "archiver": "5.3.0", "chalk": "4.1.0", "commander": "9.4.1", @@ -49,7 +49,7 @@ "bugs": "https://github.com/pattern-lab/patternlab-node/issues", "license": "MIT", "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/core/.nvmrc b/packages/core/.nvmrc index 8aeef54f8..59ea99ee6 100644 --- a/packages/core/.nvmrc +++ b/packages/core/.nvmrc @@ -1 +1 @@ -14.21 +16.20 diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index eef54297b..1dbed1bf9 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/core + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) diff --git a/packages/core/package.json b/packages/core/package.json index 5e82b674c..74b3555ed 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,12 +1,12 @@ { "name": "@pattern-lab/core", "description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.", - "version": "6.0.1", + "version": "6.1.0", "main": "./src/index.js", "dependencies": { - "@pattern-lab/engine-handlebars": "^6.0.0", - "@pattern-lab/engine-mustache": "^6.0.0", - "@pattern-lab/live-server": "^6.0.0", + "@pattern-lab/engine-handlebars": "^6.1.0", + "@pattern-lab/engine-mustache": "^6.1.0", + "@pattern-lab/live-server": "^6.1.0", "chalk": "4.1.0", "chokidar": "3.5.1", "dive": "0.5.0", @@ -65,7 +65,7 @@ "test": "tap test/*_tests.js --reporter spec --coverage" }, "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/core/src/lib/expandPartials.js b/packages/core/src/lib/expandPartials.js index d9f7fad8e..e4976fe8b 100644 --- a/packages/core/src/lib/expandPartials.js +++ b/packages/core/src/lib/expandPartials.js @@ -1,12 +1,10 @@ 'use strict'; const logger = require('./log'); -const ph = require('./parameter_hunter'); const jsonCopy = require('./json_copy'); const getPartial = require('./get'); -const parameter_hunter = new ph(); - +// TODO: remove when removing mustache module.exports = function (currentPattern, patternlab) { const processRecursive = require('./processRecursive'); @@ -23,56 +21,46 @@ module.exports = function (currentPattern, patternlab) { ) { logger.debug(`found partials for ${currentPattern.patternPartial}`); - // determine if the template contains any pattern parameters. if so they - // must be immediately consumed - return parameter_hunter - .find_parameters(currentPattern, patternlab) - .then(() => { - //do something with the regular old partials - foundPatternPartials.forEach((foundPartial) => { - const partial = currentPattern.findPartial(foundPartial); - const partialPattern = getPartial(partial, patternlab); + //do something with the regular old partials + foundPatternPartials.forEach((foundPartial) => { + const partial = currentPattern.findPartial(foundPartial); + const partialPattern = getPartial(partial, patternlab); - //recurse through nested partials to fill out this extended template. - return processRecursive(partialPattern.relPath, patternlab) - .then(() => { - //eslint-disable-line no-loop-func + //recurse through nested partials to fill out this extended template. + return processRecursive(partialPattern.relPath, patternlab) + .then(() => { + //eslint-disable-line no-loop-func - //complete assembly of extended template - //create a copy of the partial so as to not pollute it after the getPartial call. - const cleanPartialPattern = jsonCopy( - partialPattern, - `partial pattern ${partial}` - ); + //complete assembly of extended template + //create a copy of the partial so as to not pollute it after the getPartial call. + const cleanPartialPattern = jsonCopy( + partialPattern, + `partial pattern ${partial}` + ); - //this is what we came here for - logger.debug( - `within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate` - ); + //this is what we came here for + logger.debug( + `within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate` + ); - currentPattern.extendedTemplate = - currentPattern.extendedTemplate.replace( - foundPartial, - cleanPartialPattern.extendedTemplate - ); + currentPattern.extendedTemplate = + currentPattern.extendedTemplate.replace( + foundPartial, + cleanPartialPattern.extendedTemplate + ); - // update the extendedTemplate in the partials object in case this - // pattern is consumed later - patternlab.partials[currentPattern.patternPartial] = - currentPattern.extendedTemplate; + // update the extendedTemplate in the partials object in case this + // pattern is consumed later + patternlab.partials[currentPattern.patternPartial] = + currentPattern.extendedTemplate; - return Promise.resolve(); - }) - .catch((reason) => { - console.log(reason); - logger.error(reason); - }); + return Promise.resolve(); + }) + .catch((reason) => { + console.log(reason); + logger.error(reason); }); - }) - .catch((reason) => { - console.log(reason); - logger.error(reason); - }); + }); } return Promise.resolve(); }; diff --git a/packages/core/src/lib/parameter_hunter.js b/packages/core/src/lib/parameter_hunter.js deleted file mode 100644 index 01a260ffc..000000000 --- a/packages/core/src/lib/parameter_hunter.js +++ /dev/null @@ -1,339 +0,0 @@ -'use strict'; - -const getPartial = require('./get'); -const logger = require('./log'); -const parseLink = require('./parseLink'); -const jsonCopy = require('./json_copy'); -const replaceParameter = require('./replaceParameter'); - -const parameter_hunter = function () { - /** - * This function is really to accommodate the lax JSON-like syntax allowed by - * Pattern Lab PHP for parameter submissions to partials. Unfortunately, no - * easily searchable library was discovered for this. What we had to do was - * write a custom script to crawl through the parameter string, and wrap the - * keys and values in double-quotes as necessary. - * The steps on a high-level are as follows: - * * Further escape all escaped quotes and colons. Use the string - * representation of their unicodes for this. This has the added bonus - * of being interpreted correctly by JSON.parse() without further - * modification. This will be useful later in the function. - * * Once escaped quotes are out of the way, we know the remaining quotes - * are either key/value wrappers or wrapped within those wrappers. We know - * that remaining commas and colons are either delimiters, or wrapped - * within quotes to not be recognized as such. - * * A do-while loop crawls paramString to write keys to a keys array and - * values to a values array. - * * Start by parsing the first key. Determine the type of wrapping quote, - * if any. - * * By knowing the open wrapper, we know that the next quote of that kind - * (if the key is wrapped in quotes), HAS to be the close wrapper. - * Similarly, if the key is unwrapped, we know the next colon HAS to be - * the delimiter between key and value. - * * Save the key to the keys array. - * * Next, search for a value. It will either be the next block wrapped in - * quotes, or a string of alphanumerics, decimal points, or minus signs. - * * Save the value to the values array. - * * The do-while loop truncates the paramString value while parsing. Its - * condition for completion is when the paramString is whittled down to an - * empty string. - * * After the keys and values arrays are built, a for loop iterates through - * them to build the final paramStringWellFormed string. - * * No quote substitution had been done prior to this loop. In this loop, - * all keys are ensured to be wrapped in double-quotes. String values are - * also ensured to be wrapped in double-quotes. - * * Unescape escaped unicodes except for double-quotes. Everything beside - * double-quotes will be wrapped in double-quotes without need for escape. - * * Return paramStringWellFormed. - * - * @param {string} pString - * @returns {string} paramStringWellFormed - */ - function paramToJson(pString) { - let colonPos = -1; - const keys = []; - let paramString = pString; // to not reassign param - let paramStringWellFormed; - let quotePos = -1; - let regex; - const values = []; - let wrapper; - - // attempt to parse the data in case it is already well formed JSON - try { - paramStringWellFormed = JSON.stringify(JSON.parse(pString)); - return paramStringWellFormed; - } catch (err) { - logger.debug( - `Not valid JSON found for passed pattern parameter ${pString} will attempt to parse manually...` - ); - } - - //replace all escaped double-quotes with escaped unicode - paramString = paramString.replace(/\\"/g, '\\u0022'); - - //replace all escaped single-quotes with escaped unicode - paramString = paramString.replace(/\\'/g, '\\u0027'); - - //replace all escaped colons with escaped unicode - paramString = paramString.replace(/\\:/g, '\\u0058'); - - //with escaped chars out of the way, crawl through paramString looking for - //keys and values - do { - //check if searching for a key - if (paramString[0] === '{' || paramString[0] === ',') { - paramString = paramString.substring(1, paramString.length).trim(); - - //search for end quote if wrapped in quotes. else search for colon. - //everything up to that position will be saved in the keys array. - switch (paramString[0]) { - //need to search for end quote pos in case the quotes wrap a colon - case '"': - case "'": - wrapper = paramString[0]; - quotePos = paramString.indexOf(wrapper, 1); - break; - - default: - colonPos = paramString.indexOf(':'); - } - - if (quotePos > -1) { - keys.push(paramString.substring(0, quotePos + 1).trim()); - - //truncate the beginning from paramString and look for a value - paramString = paramString - .substring(quotePos + 1, paramString.length) - .trim(); - - //unset quotePos - quotePos = -1; - } else if (colonPos > -1) { - keys.push(paramString.substring(0, colonPos).trim()); - - //truncate the beginning from paramString and look for a value - paramString = paramString.substring(colonPos, paramString.length); - - //unset colonPos - colonPos = -1; - - //if there are no more colons, and we're looking for a key, there is - //probably a problem. stop any further processing. - } else { - paramString = ''; - break; - } - } - - //now, search for a value - if (paramString[0] === ':') { - paramString = paramString.substring(1, paramString.length).trim(); - - //the only reason we're using regexes here, instead of indexOf(), is - //because we don't know if the next delimiter is going to be a comma or - //a closing curly brace. since it's not much of a performance hit to - //use regexes as sparingly as here, and it's much more concise and - //readable, we'll use a regex for match() and replace() instead of - //performing conditional logic with indexOf(). - switch (paramString[0]) { - //since a quote of same type as its wrappers would be escaped, and we - //escaped those even further with their unicodes, it is safe to look - //for wrapper pairs and conclude that their contents are values - case '"': - regex = /^"(.|\s)*?"/; - break; - case "'": - regex = /^'(.|\s)*?'/; - break; - - //if there is no value wrapper, regex for alphanumerics, decimal - //points, and minus signs for exponential notation. - default: - regex = /^[\w\-\.]*/; - } - values.push(paramString.match(regex)[0].trim()); - - //truncate the beginning from paramString and continue either - //looking for a key, or returning - paramString = paramString.replace(regex, '').trim(); - - //exit do while if the final char is '}' - if (paramString === '}') { - paramString = ''; - break; - } - - //if there are no more colons, and we're looking for a value, there is - //probably a problem. stop any further processing. - } else { - paramString = ''; - break; - } - } while (paramString); - - //build paramStringWellFormed string for JSON parsing - paramStringWellFormed = '{'; - for (let i = 0; i < keys.length; i++) { - //keys - //replace single-quote wrappers with double-quotes - if (keys[i][0] === "'" && keys[i][keys[i].length - 1] === "'") { - paramStringWellFormed += '"'; - - //any enclosed double-quotes must be escaped - paramStringWellFormed += keys[i] - .substring(1, keys[i].length - 1) - .replace(/"/g, '\\"'); - paramStringWellFormed += '"'; - } else { - //open wrap with double-quotes if no wrapper - if (keys[i][0] !== '"' && keys[i][0] !== "'") { - paramStringWellFormed += '"'; - - //this is to clean up vestiges from Pattern Lab PHP's escaping scheme. - //F.Y.I. Pattern Lab PHP would allow special characters like question - //marks in parameter keys so long as the key was unwrapped and the - //special character escaped with a backslash. In Node, we need to wrap - //those keys and unescape those characters. - keys[i] = keys[i].replace(/\\/g, ''); - } - - paramStringWellFormed += keys[i]; - - //close wrap with double-quotes if no wrapper - if ( - keys[i][keys[i].length - 1] !== '"' && - keys[i][keys[i].length - 1] !== "'" - ) { - paramStringWellFormed += '"'; - } - } - - //colon delimiter. - paramStringWellFormed += ':'; - - //values - //replace single-quote wrappers with double-quotes - if (values[i][0] === "'" && values[i][values[i].length - 1] === "'") { - paramStringWellFormed += '"'; - - //any enclosed double-quotes must be escaped - paramStringWellFormed += values[i] - .substring(1, values[i].length - 1) - .replace(/"/g, '\\"'); - paramStringWellFormed += '"'; - - //for everything else, just add the value however it's wrapped - } else { - paramStringWellFormed += values[i]; - } - - //comma delimiter - if (i < keys.length - 1) { - paramStringWellFormed += ','; - } - } - paramStringWellFormed += '}'; - - //unescape escaped unicode except for double-quotes - paramStringWellFormed = paramStringWellFormed.replace(/\\u0027/g, "'"); - paramStringWellFormed = paramStringWellFormed.replace(/\\u0058/g, ':'); - - return paramStringWellFormed; - } - - //compile this partial immeadiately, essentially consuming it. - function findparameters(pattern, patternlab) { - if (pattern.parameteredPartials && pattern.parameteredPartials.length > 0) { - logger.debug(`processing patternParameters for ${pattern.patternName}`); - - return pattern.parameteredPartials.reduce((previousPromise, pMatch) => { - return previousPromise - .then(() => { - logger.debug(`processing patternParameter ${pMatch}`); - - //find the partial's name and retrieve it - const partialName = pMatch.match(/([\w\-\.\/~]+)/g)[0]; - const partialPattern = jsonCopy( - getPartial( - partialName, - patternlab, - `partial pattern ${partialName}` - ) - ); - - //if we retrieved a pattern we should make sure that its extendedTemplate is reset. looks to fix #190 - if (!partialPattern.extendedTemplate) { - partialPattern.extendedTemplate = partialPattern.template; - } - - if (!pattern.extendedTemplate) { - pattern.extendedTemplate = pattern.template; - } - - logger.debug(`retrieved pattern ${partialName}`); - - //strip out the additional data, convert string to JSON. - const leftParen = pMatch.indexOf('('); - const rightParen = pMatch.lastIndexOf(')'); - const paramString = - '{' + pMatch.substring(leftParen + 1, rightParen) + '}'; - const paramStringWellFormed = paramToJson(paramString); - - let paramData = {}; - - try { - paramData = JSON.parse(paramStringWellFormed); - } catch (err) { - logger.warning( - `There was a problem parsing JSON parameters for ${pattern.relPath}` - ); - logger.warning(err); - } - - // resolve any pattern links that might be present - paramData = parseLink( - patternlab, - paramData, - pattern.patternPartial - ); - - // for each property in paramData - for (const prop in paramData) { - if (paramData.hasOwnProperty(prop)) { - // find it within partialPattern.extendedTemplate and replace its value - partialPattern.extendedTemplate = replaceParameter( - partialPattern.extendedTemplate, - prop, - paramData[prop] - ); - } - } - - // set pattern.extendedTemplate pMatch with replacedPartial - pattern.extendedTemplate = pattern.extendedTemplate.replace( - pMatch, - partialPattern.extendedTemplate - ); - - //todo: this no longer needs to be a promise - return Promise.resolve(); - }) - .catch((reason) => { - console.log(reason); - logger.error(reason); - }); - }, Promise.resolve()); - } - logger.debug(`pattern has no partials ${pattern.patternPartial}`); - return Promise.resolve(); - } - - return { - find_parameters: function (pattern, patternlab) { - return findparameters(pattern, patternlab); - }, - }; -}; - -module.exports = parameter_hunter; diff --git a/packages/core/test/parameter_hunter_tests.js b/packages/core/test/parameter_hunter_tests.js deleted file mode 100644 index b19314d10..000000000 --- a/packages/core/test/parameter_hunter_tests.js +++ /dev/null @@ -1,462 +0,0 @@ -'use strict'; - -const path = require('path'); -const util = require('./util/test_utils.js'); -const tap = require('tap'); - -const loadPattern = require('../src/lib/loadPattern'); -const ph = require('../src/lib/parameter_hunter'); -const processIterative = require('../src/lib/processIterative'); - -const parameter_hunter = new ph(); - -const config = require('./util/patternlab-config.json'); -const engineLoader = require('../src/lib/pattern_engines'); -engineLoader.loadAllEngines(config); - -const testPatternsPath = path.resolve(__dirname, 'files', '_patterns'); - -tap.test('parameter hunter finds and extends templates', function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]) - .then(() => { - //act - parameter_hunter - .find_parameters(testPattern, pl) - .then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized( - '
A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
' - ) - ); - test.end(); - }) - .catch(test.threw); - }) - .catch(test.threw); -}); - -tap.test( - 'parameter hunter finds and extends templates with verbose partials', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment-verbose.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]) - .then(() => { - //act - parameter_hunter - .find_parameters(testPattern, pl) - .then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized( - 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
' - ) - ); - test.end(); - }) - .catch(test.threw); - }) - .catch(test.threw); - } -); - -//previous tests were for unquoted parameter keys and single-quoted values. -//test other quoting options. -tap.test( - 'parameter hunter parses parameters with unquoted keys and unquoted values', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = '{{> test-comment(description: true) }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with unquoted keys and double-quoted values', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = '{{> test-comment(description: "true") }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with single-quoted keys and unquoted values', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = "{{> test-comment('description': true) }}"; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with single-quoted keys and single-quoted values wrapping internal escaped single-quotes', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - "{{> test-comment('description': 'true not,\\'true\\'') }}"; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized(`true not,'true'
`) - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with single-quoted keys and double-quoted values wrapping internal single-quotes', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - "{{> test-comment('description': \"true not:'true'\") }}"; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized(`true not:'true'
`) - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with double-unquoted keys and unquoted values', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = '{{> test-comment("description": true) }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with double-quoted keys and single-quoted values wrapping internal double-quotes', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - '{{> test-comment("description": \'true not{"true"\') }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true not{"true"
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with double-quoted keys and double-quoted values wrapping internal escaped double-quotes', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - '{{> test-comment("description": "true not}\\"true\\"") }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true not}"true"
') - ); - test.end(); - }); - }); - } -); - -tap.test( - 'parameter hunter parses parameters with combination of quoting schemes for keys and values', - function (test) { - //arrange - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - '{{> test-comment(description: true, \'foo\': false, "bar": false, \'single\': true, \'singlesingle\': \'true\', \'singledouble\': "true", "double": true, "doublesingle": \'true\', "doubledouble": "true") }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('true
') - ); - test.end(); - }); - }); - } -); - -//todo https://github.com/pattern-lab/patternlab-node/issues/673 -// tap.test('parameter hunter parses parameters with values containing a closing parenthesis', function (test) { -// //arrange -// const pl = util.fakePatternLab(testPatternsPath); - -// var commentPath = path.join('test', 'comment.mustache'); -// var commentPattern = loadPattern(commentPath, pl); - -// var testPatternPath = path.join('test', 'sticky-comment.mustache'); -// var testPattern = loadPattern(testPatternPath, pl); - -// //override the file -// testPattern.template = "{{> test-comment(description: 'Hello ) World') }}"; -// testPattern.extendedTemplate = testPattern.template; -// testPattern.parameteredPartials[0] = testPattern.template; - -// var p1 = processIterative(commentPattern, pl); -// var p2 = processIterative(testPattern, pl); - -// Promise.all([p1, p2]).then(() => { -// //act -// parameter_hunter.find_parameters(testPattern, pl).then(() => { -// //assert -// test.equal(util.sanitized(testPattern.extendedTemplate), util.sanitized('Hello ) World
')); -// test.end(); -// }); -// }); -// }); - -tap.test('parameter hunter skips malformed parameters', function (test) { - const pl = util.fakePatternLab(testPatternsPath); - - var commentPath = path.join('test', 'comment.mustache'); - var commentPattern = loadPattern(commentPath, pl); - - var testPatternPath = path.join('test', 'sticky-comment.mustache'); - var testPattern = loadPattern(testPatternPath, pl); - - //override the file - testPattern.template = - '{{> test-comment( missing-val: , : missing-key, : , , foo: "Hello World") }}'; - testPattern.extendedTemplate = testPattern.template; - testPattern.parameteredPartials[0] = testPattern.template; - - var p1 = processIterative(commentPattern, pl); - var p2 = processIterative(testPattern, pl); - - Promise.all([p1, p2]).then(() => { - //act - parameter_hunter.find_parameters(testPattern, pl).then(() => { - //assert - console.log( - '\nPattern Lab should catch JSON.parse() errors and output useful debugging information...' - ); - test.equal( - util.sanitized(testPattern.extendedTemplate), - util.sanitized('{{description}}
') - ); - test.end(); - }); - }); -}); diff --git a/packages/create/CHANGELOG.md b/packages/create/CHANGELOG.md index a488c4511..edc41d235 100644 --- a/packages/create/CHANGELOG.md +++ b/packages/create/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package create-pattern-lab + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) **Note:** Version bump only for package create-pattern-lab diff --git a/packages/create/package.json b/packages/create/package.json index 48d67ba5a..2785e53c6 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -1,12 +1,12 @@ { "name": "create-pattern-lab", - "version": "6.0.1", + "version": "6.1.0", "description": "", "bin": "index.js", "main": "index.js", "scripts": {}, "dependencies": { - "@pattern-lab/cli": "^6.0.1" + "@pattern-lab/cli": "^6.1.0" }, "author": "", "license": "MIT", @@ -15,6 +15,6 @@ }, "gitHead": "80f62be442223e09bafb30d0529cbd768e03f2ac", "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" } } diff --git a/packages/development-edition-engine-handlebars/.nvmrc b/packages/development-edition-engine-handlebars/.nvmrc index 8aeef54f8..59ea99ee6 100644 --- a/packages/development-edition-engine-handlebars/.nvmrc +++ b/packages/development-edition-engine-handlebars/.nvmrc @@ -1 +1 @@ -14.21 +16.20 diff --git a/packages/development-edition-engine-handlebars/CHANGELOG.md b/packages/development-edition-engine-handlebars/CHANGELOG.md index c4030bb02..635e4b857 100644 --- a/packages/development-edition-engine-handlebars/CHANGELOG.md +++ b/packages/development-edition-engine-handlebars/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/development-edition-engine-handlebars + + + + + +## [6.0.3](https://github.com/pattern-lab/patternlab-node/compare/v6.0.2...v6.0.3) (2023-03-12) + +**Note:** Version bump only for package @pattern-lab/development-edition-engine-handlebars + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) **Note:** Version bump only for package @pattern-lab/development-edition-engine-handlebars diff --git a/packages/development-edition-engine-handlebars/package.json b/packages/development-edition-engine-handlebars/package.json index a670d18ac..52c59b7d6 100644 --- a/packages/development-edition-engine-handlebars/package.json +++ b/packages/development-edition-engine-handlebars/package.json @@ -1,7 +1,7 @@ { "name": "@pattern-lab/development-edition-engine-handlebars", "private": true, - "version": "6.0.1", + "version": "6.1.0", "description": "The tree of components we use to test, develop and validate the Handlebars engine", "scripts": { "pl:build": "patternlab build --config ./patternlab-config.json", @@ -26,15 +26,15 @@ "url": "git://github.com/pattern-lab/patternlab-node.git" }, "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" }, "dependencies": { - "@pattern-lab/cli": "^6.0.1", - "@pattern-lab/core": "^6.0.1", - "@pattern-lab/engine-handlebars": "^6.0.0", - "@pattern-lab/engine-mustache": "^6.0.0", - "@pattern-lab/plugin-tab": "^6.0.0", - "@pattern-lab/starterkit-handlebars-demo": "^6.0.0", - "@pattern-lab/uikit-workshop": "^6.0.1" + "@pattern-lab/cli": "^6.1.0", + "@pattern-lab/core": "^6.1.0", + "@pattern-lab/engine-handlebars": "^6.1.0", + "@pattern-lab/engine-mustache": "^6.1.0", + "@pattern-lab/plugin-tab": "^6.1.0", + "@pattern-lab/starterkit-handlebars-demo": "^6.1.0", + "@pattern-lab/uikit-workshop": "^6.1.0" } } diff --git a/packages/development-edition-engine-react/.nvmrc b/packages/development-edition-engine-react/.nvmrc index 8aeef54f8..59ea99ee6 100644 --- a/packages/development-edition-engine-react/.nvmrc +++ b/packages/development-edition-engine-react/.nvmrc @@ -1 +1 @@ -14.21 +16.20 diff --git a/packages/development-edition-engine-react/CHANGELOG.md b/packages/development-edition-engine-react/CHANGELOG.md index b4d1b5e4f..6924275e4 100644 --- a/packages/development-edition-engine-react/CHANGELOG.md +++ b/packages/development-edition-engine-react/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/edition-node-gulp/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/engine-react-testing-tree + + + + + +## [6.0.3](https://github.com/pattern-lab/edition-node-gulp/compare/v6.0.2...v6.0.3) (2023-03-12) + +**Note:** Version bump only for package @pattern-lab/engine-react-testing-tree + + + + + ## [6.0.1](https://github.com/pattern-lab/edition-node-gulp/compare/v6.0.0...v6.0.1) (2023-02-01) **Note:** Version bump only for package @pattern-lab/engine-react-testing-tree diff --git a/packages/development-edition-engine-react/package.json b/packages/development-edition-engine-react/package.json index bac5a0983..ed5c6f21d 100644 --- a/packages/development-edition-engine-react/package.json +++ b/packages/development-edition-engine-react/package.json @@ -1,14 +1,14 @@ { "name": "@pattern-lab/engine-react-testing-tree", "description": "The tree of components we use to test, develop and validate the React engine", - "version": "6.0.1", + "version": "6.1.0", "private": true, "main": "gulpfile.js", "dependencies": { - "@pattern-lab/core": "^6.0.1", - "@pattern-lab/engine-mustache": "^6.0.0", - "@pattern-lab/engine-react": "^6.0.0", - "@pattern-lab/uikit-workshop": "^6.0.1", + "@pattern-lab/core": "^6.1.0", + "@pattern-lab/engine-mustache": "^6.1.0", + "@pattern-lab/engine-react": "^6.1.0", + "@pattern-lab/uikit-workshop": "^6.1.0", "gulp": "4.0.2", "minimist": "^1.2.5", "react": "16.2.0" @@ -31,6 +31,6 @@ }, "license": "MIT", "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" } } diff --git a/packages/development-edition-engine-twig/CHANGELOG.md b/packages/development-edition-engine-twig/CHANGELOG.md index dcc88cda4..86702f2f3 100644 --- a/packages/development-edition-engine-twig/CHANGELOG.md +++ b/packages/development-edition-engine-twig/CHANGELOG.md @@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/pattern-lab/patternlab-node/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/development-edition-engine-twig + + + + + +## [6.0.3](https://github.com/pattern-lab/patternlab-node/compare/v6.0.2...v6.0.3) (2023-03-12) + +**Note:** Version bump only for package @pattern-lab/development-edition-engine-twig + + + + + +## [6.0.2](https://github.com/pattern-lab/patternlab-node/compare/v6.0.1...v6.0.2) (2023-02-26) + + +### Bug Fixes + +* **starterkit-twig-demo:** pages not rendering pattern-specific data from json ([#1490](https://github.com/pattern-lab/patternlab-node/issues/1490)) ([1c878df](https://github.com/pattern-lab/patternlab-node/commit/1c878dfa35d549f23e199b3e235ff79cb471ac86)), closes [#1486](https://github.com/pattern-lab/patternlab-node/issues/1486) + + + + + ## [6.0.1](https://github.com/pattern-lab/patternlab-node/compare/v6.0.0...v6.0.1) (2023-02-01) **Note:** Version bump only for package @pattern-lab/development-edition-engine-twig diff --git a/packages/development-edition-engine-twig/package.json b/packages/development-edition-engine-twig/package.json index 8add6fb30..7b8010f68 100644 --- a/packages/development-edition-engine-twig/package.json +++ b/packages/development-edition-engine-twig/package.json @@ -1,7 +1,7 @@ { "name": "@pattern-lab/development-edition-engine-twig", "private": true, - "version": "6.0.1", + "version": "6.1.0", "description": "The tree of components we use to test, develop and validate the twig engine (not engine-twig-php)", "scripts": { "postbootstrap": "patternlab install --starterkits @pattern-lab/starterkit-twig-demo", @@ -27,14 +27,14 @@ "url": "git://github.com/pattern-lab/patternlab-node.git" }, "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" }, "dependencies": { - "@pattern-lab/cli": "^6.0.1", - "@pattern-lab/core": "^6.0.1", - "@pattern-lab/engine-twig": "^6.0.0", - "@pattern-lab/starterkit-twig-demo": "^6.0.1", - "@pattern-lab/uikit-workshop": "^6.0.1" + "@pattern-lab/cli": "^6.1.0", + "@pattern-lab/core": "^6.1.0", + "@pattern-lab/engine-twig": "^6.1.0", + "@pattern-lab/starterkit-twig-demo": "^6.1.0", + "@pattern-lab/uikit-workshop": "^6.1.0" }, "workspaces": { "nohoist": [ diff --git a/packages/development-edition-engine-twig/patternlab-config.json b/packages/development-edition-engine-twig/patternlab-config.json index 8fba803bd..c50ccbcda 100644 --- a/packages/development-edition-engine-twig/patternlab-config.json +++ b/packages/development-edition-engine-twig/patternlab-config.json @@ -114,7 +114,7 @@ "organisms": "source/_patterns/organisms/", "templates": "source/_patterns/templates/", "pages": "source/_patterns/pages/", - "macros": "source/_macros/" + "macros": "source/_patterns/macros/" } } } diff --git a/packages/docs/CHANGELOG.md b/packages/docs/CHANGELOG.md index 7f5f44be0..97fdd21e5 100644 --- a/packages/docs/CHANGELOG.md +++ b/packages/docs/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [6.1.0](https://github.com/bradfrost/pl-website-eleventy/compare/v6.0.3...v6.1.0) (2023-12-21) + +**Note:** Version bump only for package @pattern-lab/website + + + + + # [6.0.0](https://github.com/bradfrost/pl-website-eleventy/compare/v5.17.0...v6.0.0) (2023-01-31) diff --git a/packages/docs/package.json b/packages/docs/package.json old mode 100755 new mode 100644 index 21a1d8887..84613c39f --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "@pattern-lab/website", - "version": "6.0.0", + "version": "6.1.0", "description": "The website for patternlab.io", "main": "index.js", "dependencies": { @@ -55,6 +55,6 @@ "homepage": "https://github.com/bradfrost/pl-website-eleventy/#readme", "gitHead": "80f62be442223e09bafb30d0529cbd768e03f2ac", "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" } } diff --git a/packages/docs/src/docs/advanced-config-options.md b/packages/docs/src/docs/advanced-config-options.md index 4665c35ca..460b79395 100644 --- a/packages/docs/src/docs/advanced-config-options.md +++ b/packages/docs/src/docs/advanced-config-options.md @@ -198,7 +198,7 @@ Other engine specific configuration options can be added and will be passed to t "engines": { "handlebars": { "package": "@pattern-lab/engine-handlebars", - "extensions": [ + "fileExtensions": [ "handlebars", "hbs" ], diff --git a/packages/docs/src/docs/pattern-parameters.md b/packages/docs/src/docs/pattern-parameters.md index 5b040e926..c41130647 100644 --- a/packages/docs/src/docs/pattern-parameters.md +++ b/packages/docs/src/docs/pattern-parameters.md @@ -11,97 +11,4 @@ sitemapPriority: '0.8' sitemapChangefreq: 'monthly' --- -**Important:** Pattern parameters are supported by the Node Mustache PatternEngines. Other template languages provide better solutions to this problem. - -Pattern parameters are a **simple** mechanism for replacing Mustache variables in an included pattern. They are limited to replacing variables in the included pattern and **only** the included pattern. They are especially useful when including a single pattern multiple times in a molecule, template, or page and you want to supply unique data to that pattern each time it's included. Pattern parameters **do not** currently support the following: - -- sub-lists (_e.g. iteration of a section_), -- long strings of text (_can be unwieldy_) -- modifying/replacing variables in patterns included _within_ the targeted pattern - -Pattern parameters are Pattern Lab-specific, have no relationship to Mustache, and are implemented outside of Mustache. Learn more about pattern parameters: - -- [The Pattern Parameter Syntax](#pattern-parameter-syntax) -- [Adding Pattern Parameters to Your Pattern Partial](#adding-pattern-parameters) -- [Toggling Sections with Pattern Parameters](#toggling-sections) - -## The Pattern Parameter Syntax - -The attributes listed in the pattern parameters need to match Mustache variable names in your pattern. The values listed for each attribute will replace the Mustache variables. For example: - - {% raw %}{{> patternGroup-pattern(attribute1: value, attribute2: "value string") }}{% endraw %} - -Again, pattern parameters are a simple find and replace of Mustache variables with the supplied values. - -## Adding Pattern Parameters to Your Pattern Partial - -Let's look at a simple example for how we might use pattern parameters. First we'll set-up a pattern that might be included multiple times. We'll make it a simple "message" pattern with a single Mustache variable of `message`. - -```html - -``` - -We'll organize it under Atoms > Global and call it "message" so it'll have the pattern partial of `atoms-message`. - -Now let's create a pattern that includes our message pattern partial multiple times. It might look like this. - -```html -{{ reverse('abc') }}
` => `cba
` */ -// $env->addFunction(new \Twig_SimpleFunction('reverse', function ($theString) { +// $env->addFunction(new TwigFunction('reverse', function ($theString) { // return strrev($theString); // })); @@ -29,6 +31,5 @@ function addCustomExtension(\Twig_Environment &$env, $config) { // $env->addGlobal('foo', 'bar'); // example of enabling the Twig debug mode extension (ex. {{ dump(my_variable) }} to check out the template's available data) -- comment out to disable - // $env->addExtension(new \Twig_Extension_Debug()); - + // $env->addExtension(new Twig\Extension\DebugExtension()); } diff --git a/packages/edition-twig/package.json b/packages/edition-twig/package.json index f239543a8..9d1c2416a 100644 --- a/packages/edition-twig/package.json +++ b/packages/edition-twig/package.json @@ -1,6 +1,6 @@ { "name": "@pattern-lab/edition-twig", - "version": "6.0.1", + "version": "6.1.0", "description": "Pattern Lab node with Twig PHP Engine", "author": { "name": "Evan Lovely", @@ -23,13 +23,13 @@ "dev": "node ./node_modules/@pattern-lab/uikit-workshop/build-tools.js" }, "dependencies": { - "@pattern-lab/cli": "^6.0.1", - "@pattern-lab/core": "^6.0.1", - "@pattern-lab/engine-twig-php": "^6.0.1", - "@pattern-lab/uikit-workshop": "^6.0.1" + "@pattern-lab/cli": "^6.1.0", + "@pattern-lab/core": "^6.1.0", + "@pattern-lab/engine-twig-php": "^6.1.0", + "@pattern-lab/uikit-workshop": "^6.1.0" }, "engines": { - "node": ">=14.21.1" + "node": ">=16.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/edition-twig/source/_patterns/atoms/buttons/button-dark-demo.twig b/packages/edition-twig/source/_patterns/atoms/buttons/button-dark-demo.twig index 636b15686..5a61b3cb7 100644 --- a/packages/edition-twig/source/_patterns/atoms/buttons/button-dark-demo.twig +++ b/packages/edition-twig/source/_patterns/atoms/buttons/button-dark-demo.twig @@ -1,4 +1,4 @@ -{% include '@atoms/buttons/_button.twig' with { +{% include '@atoms/buttons/button.twig' with { text: 'Click Me', dark: true, } only %} diff --git a/packages/edition-twig/source/_patterns/atoms/buttons/button-simple-demo.twig b/packages/edition-twig/source/_patterns/atoms/buttons/button-simple-demo.twig index ae1350317..81cf5f6cb 100644 --- a/packages/edition-twig/source/_patterns/atoms/buttons/button-simple-demo.twig +++ b/packages/edition-twig/source/_patterns/atoms/buttons/button-simple-demo.twig @@ -1,3 +1,3 @@ -{% include '@atoms/buttons/_button.twig' with { +{% include '@atoms/buttons/button.twig' with { text: 'Click Me', } only %} diff --git a/packages/edition-twig/source/_patterns/atoms/buttons/button.md b/packages/edition-twig/source/_patterns/atoms/buttons/button.md new file mode 100644 index 000000000..683af9f1a --- /dev/null +++ b/packages/edition-twig/source/_patterns/atoms/buttons/button.md @@ -0,0 +1,3 @@ +--- +hidden: true +--- diff --git a/packages/edition-twig/source/_patterns/atoms/buttons/_button.twig b/packages/edition-twig/source/_patterns/atoms/buttons/button.twig similarity index 100% rename from packages/edition-twig/source/_patterns/atoms/buttons/_button.twig rename to packages/edition-twig/source/_patterns/atoms/buttons/button.twig diff --git a/packages/edition-twig/source/_patterns/atoms/text/headings.twig b/packages/edition-twig/source/_patterns/atoms/text/headings.twig index 2ecbbf0c5..deb727bab 100644 --- a/packages/edition-twig/source/_patterns/atoms/text/headings.twig +++ b/packages/edition-twig/source/_patterns/atoms/text/headings.twig @@ -1,6 +1,6 @@