From 1094f77b9c5c890e88b9768fdf9ef16acb486d91 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Wed, 1 Feb 2023 08:26:58 +0100 Subject: [PATCH 1/3] fix: missing schema entry for twig engine --- packages/engine-twig-php/lib/engine_twig_php.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/engine-twig-php/lib/engine_twig_php.js b/packages/engine-twig-php/lib/engine_twig_php.js index d52a13ebc..874f6af03 100644 --- a/packages/engine-twig-php/lib/engine_twig_php.js +++ b/packages/engine-twig-php/lib/engine_twig_php.js @@ -57,6 +57,7 @@ const engine_twig_php = { }, relativeFrom, alterTwigEnv, + package, ...rest, }); From b9de869e693307206153a6a6b4c55d39d2578fda Mon Sep 17 00:00:00 2001 From: Josef Bredreck <13408112+JosefBredereck@users.noreply.github.com> Date: Wed, 1 Feb 2023 21:08:17 +0100 Subject: [PATCH 2/3] fix: twig php engine loading --- packages/core/package.json | 1 + packages/edition-twig/patternlab-config.json | 2 +- packages/engine-twig-php/lib/engine_twig_php.js | 14 +++++++------- .../starterkit-twig-demo/patternlab-config.json | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 835cf1ce7..9c941c398 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -4,6 +4,7 @@ "version": "6.0.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", "chalk": "4.1.0", diff --git a/packages/edition-twig/patternlab-config.json b/packages/edition-twig/patternlab-config.json index 3907ebb47..40d5301c4 100644 --- a/packages/edition-twig/patternlab-config.json +++ b/packages/edition-twig/patternlab-config.json @@ -1,6 +1,6 @@ { "engines": { - "twig": { + "twig-php": { "package": "@pattern-lab/engine-twig-php", "fileExtensions": [ "twig" diff --git a/packages/engine-twig-php/lib/engine_twig_php.js b/packages/engine-twig-php/lib/engine_twig_php.js index 874f6af03..0f728dc6b 100644 --- a/packages/engine-twig-php/lib/engine_twig_php.js +++ b/packages/engine-twig-php/lib/engine_twig_php.js @@ -40,13 +40,17 @@ const engine_twig_php = { usePatternLabConfig: function (config) { patternLabConfig = config; - if (!config.engines.twig) { + if (!config.engines['twig-php']) { console.error('Missing "twig" in Pattern Lab config file; exiting...'); process.exit(1); } const { namespaces, alterTwigEnv, relativeFrom, ...rest } = - config.engines.twig; + config.engines['twig-php']; + + // since package is a reserved word in node, we need to delete it from the config object like this + delete rest.package; + delete rest.fileExtensions; // Schema on config object being passed in: // https://github.com/basaltinc/twig-renderer/blob/master/config.schema.json @@ -57,7 +61,6 @@ const engine_twig_php = { }, relativeFrom, alterTwigEnv, - package, ...rest, }); @@ -222,10 +225,7 @@ const engine_twig_php = { // then tease out the folder name itself (including the # prefix) // ex. atoms - const folderName = fullFolderPath.substring( - fullFolderPath.lastIndexOf('/') + 1, - fullFolderPath.length - ); + const folderName = path.parse(fullFolderPath).base; // finally, return the Twig path we created from the full file path // ex. atoms/buttons/button.twig diff --git a/packages/starterkit-twig-demo/patternlab-config.json b/packages/starterkit-twig-demo/patternlab-config.json index c25133362..099f03c03 100644 --- a/packages/starterkit-twig-demo/patternlab-config.json +++ b/packages/starterkit-twig-demo/patternlab-config.json @@ -1,6 +1,6 @@ { "engines": { - "twig": { + "twig-php": { "package": "@pattern-lab/engine-twig-php", "fileExtensions": [ "twig" From 89c8fb8890c7e753c2ceaa1358e31a76fd83915e Mon Sep 17 00:00:00 2001 From: Josef Bredreck <13408112+JosefBredereck@users.noreply.github.com> Date: Wed, 1 Feb 2023 21:16:13 +0100 Subject: [PATCH 3/3] fix: error message if partial could not be found --- packages/core/src/lib/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/lib/get.js b/packages/core/src/lib/get.js index 4852670eb..2f180a77f 100644 --- a/packages/core/src/lib/get.js +++ b/packages/core/src/lib/get.js @@ -35,7 +35,7 @@ module.exports = function (partialName, patternlab, reportWarning = true) { } if (reportWarning) { logger.warning( - `Could not find pattern referenced with partial syntax ${partialName}. + `Could not find pattern referenced with partial syntax "${partialName}" from "${patternlab.config.paths.source.patterns}". This can occur when a pattern was renamed, moved, or no longer exists but it still referenced within a different template or within data as a link.` ); }