Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(twig engine): startup and running problems #1478

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/edition-twig/patternlab-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"engines": {
"twig": {
"twig-php": {
"package": "@pattern-lab/engine-twig-php",
"fileExtensions": [
"twig"
Expand Down
13 changes: 7 additions & 6 deletions packages/engine-twig-php/lib/engine_twig_php.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -221,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
Expand Down
2 changes: 1 addition & 1 deletion packages/starterkit-twig-demo/patternlab-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"engines": {
"twig": {
"twig-php": {
"package": "@pattern-lab/engine-twig-php",
"fileExtensions": [
"twig"
Expand Down