Skip to content

Commit cc0d797

Browse files
authored
Merge pull request #1046 from zhawkins/feature/1045--pseudo-twigphp
fix(engine_twig_php): Pseudo patterns Twig PHP
2 parents 83a6ad4 + 257019a commit cc0d797

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ const engine_twig_php = {
6161

6262
renderPattern(pattern, data) {
6363
return new Promise((resolve, reject) => {
64-
const patternPath = path.isAbsolute(pattern.relPath)
65-
? path.relative(patternLabConfig.paths.source.root, pattern.relPath)
64+
// If this is a pseudo pattern the relPath will be incorrect.
65+
// i.e. /path/to/pattern.json
66+
// Twig can't render that file so we need to use the base patterns
67+
// relPath instead.
68+
const relPath = pattern.isPseudoPattern
69+
? pattern.basePattern.relPath
6670
: pattern.relPath;
71+
72+
const patternPath = path.isAbsolute(relPath)
73+
? path.relative(patternLabConfig.paths.source.root, relPath)
74+
: relPath;
6775
// console.log(patternPath);
6876

6977
let details = '';

0 commit comments

Comments
 (0)