Skip to content

Commit e5a1904

Browse files
fix(twig engine): startup and running problems (#1478)
* fix: missing schema entry for twig engine * fix: twig php engine loading * fix: error message if partial could not be found --------- Co-authored-by: Josef Bredreck <[email protected]>
1 parent e721091 commit e5a1904

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "6.0.0",
55
"main": "./src/index.js",
66
"dependencies": {
7+
"@pattern-lab/engine-handlebars": "^6.0.0",
78
"@pattern-lab/engine-mustache": "^6.0.0",
89
"@pattern-lab/live-server": "^6.0.0",
910
"chalk": "4.1.0",

packages/core/src/lib/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = function (partialName, patternlab, reportWarning = true) {
3535
}
3636
if (reportWarning) {
3737
logger.warning(
38-
`Could not find pattern referenced with partial syntax ${partialName}.
38+
`Could not find pattern referenced with partial syntax "${partialName}" from "${patternlab.config.paths.source.patterns}".
3939
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.`
4040
);
4141
}

packages/edition-twig/patternlab-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"engines": {
3-
"twig": {
3+
"twig-php": {
44
"package": "@pattern-lab/engine-twig-php",
55
"fileExtensions": [
66
"twig"

packages/engine-twig-php/lib/engine_twig_php.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ const engine_twig_php = {
4040
usePatternLabConfig: function (config) {
4141
patternLabConfig = config;
4242

43-
if (!config.engines.twig) {
43+
if (!config.engines['twig-php']) {
4444
console.error('Missing "twig" in Pattern Lab config file; exiting...');
4545
process.exit(1);
4646
}
4747

4848
const { namespaces, alterTwigEnv, relativeFrom, ...rest } =
49-
config.engines.twig;
49+
config.engines['twig-php'];
50+
51+
// since package is a reserved word in node, we need to delete it from the config object like this
52+
delete rest.package;
53+
delete rest.fileExtensions;
5054

5155
// Schema on config object being passed in:
5256
// https://github.com/basaltinc/twig-renderer/blob/master/config.schema.json
@@ -221,10 +225,7 @@ const engine_twig_php = {
221225

222226
// then tease out the folder name itself (including the # prefix)
223227
// ex. atoms
224-
const folderName = fullFolderPath.substring(
225-
fullFolderPath.lastIndexOf('/') + 1,
226-
fullFolderPath.length
227-
);
228+
const folderName = path.parse(fullFolderPath).base;
228229

229230
// finally, return the Twig path we created from the full file path
230231
// ex. atoms/buttons/button.twig

packages/starterkit-twig-demo/patternlab-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"engines": {
3-
"twig": {
3+
"twig-php": {
44
"package": "@pattern-lab/engine-twig-php",
55
"fileExtensions": [
66
"twig"

0 commit comments

Comments
 (0)