Skip to content

Commit b9de869

Browse files
fix: twig php engine loading
1 parent 1094f77 commit b9de869

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-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/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 & 7 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
@@ -57,7 +61,6 @@ const engine_twig_php = {
5761
},
5862
relativeFrom,
5963
alterTwigEnv,
60-
package,
6164
...rest,
6265
});
6366

@@ -222,10 +225,7 @@ const engine_twig_php = {
222225

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

230230
// finally, return the Twig path we created from the full file path
231231
// 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)