Skip to content

Reference The Correct Template In Psuedo Patterns If JSON File and Template Live in Different Folders #23

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

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions src/PatternLab/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ protected function generatePatterns($options = array()) {
// modify the pattern mark-up
$markup = $patternStoreData["code"];
$markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"];


/** If the base template for a JSON / Yaml file (or psuedo pattern variation) lives in a different folder,
* use the `original` pattern's template instead.
* Fixes https://github.com/drupal-pattern-lab/patternlab-php-core/issues/22
*/
if (!file_exists($patternSourceDir."/".$pathName.".".$patternExtension)){
$originalPatternPathName = PatternData::getOption($patternStoreData["original"])["pathName"];
if (file_exists($patternSourceDir."/".$originalPatternPathName.".".$patternExtension)){
$pathName = $originalPatternPathName;
}
}


$markupEngine = file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension);

// if the pattern directory doesn't exist create it
Expand Down