Skip to content

Commit 8151536

Browse files
committed
fix: working fix to address PL referencing template paths to psuedo-patterns which don't exist. Addresses #22
1 parent 30ab3d0 commit 8151536

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/PatternLab/Builder.php

+14
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@ protected function generatePatterns($options = array()) {
261261
// modify the pattern mark-up
262262
$markup = $patternStoreData["code"];
263263
$markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"];
264+
265+
266+
/** If the base template for a JSON / Yaml file (or psuedo pattern variation) lives in a different folder,
267+
* use the `original` pattern's template instead.
268+
* Fixes https://github.com/drupal-pattern-lab/patternlab-php-core/issues/22
269+
*/
270+
if (!file_exists($patternSourceDir."/".$pathName.".".$patternExtension)){
271+
$originalPatternPathName = PatternData::getOption($patternStoreData["original"])["pathName"];
272+
if (file_exists($patternSourceDir."/".$originalPatternPathName.".".$patternExtension)){
273+
$pathName = $originalPatternPathName;
274+
}
275+
}
276+
277+
264278
$markupEngine = file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension);
265279

266280
// if the pattern directory doesn't exist create it

0 commit comments

Comments
 (0)