Skip to content
Closed
Changes from 1 commit
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
Next Next commit
1st pass at updating how PL template lineage matches are handled, eve…
…n if the regex for a lineage matches up.

Addresses an ongoing issue where the pattern viewer doesn’t correctly display matched lineages of Twig partials when the @ namespace full path is used (vs the shorthand PL path syntax).
  • Loading branch information
bolt-bot committed Nov 21, 2016
commit 338d8014165522907f000a3f0db63997629fe667
34 changes: 34 additions & 0 deletions src/PatternLab/PatternData/Helpers/LineageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ public function run() {

foreach ($foundLineages as $lineage) {

//Handle instances where we aren't or can't use the shorthand PL path reference in templates, specifically in Twig / D8 when we need to use Twig namespaces in our template paths.
if ($lineage[0] == '@'){

//Grab the template extension getting used so we can strip it off down below.
$patternExtension = Config::getOption("patternExtension");

//Store the length of our broken up path for reference below
$length = count($lineageParts);

//Strip off the @ sign at the beginning of our $lineage string.
$lineage = ltrim($lineage, '@');
//Break apart the full lineage path based on any slashes that may exist.
$lineageParts = explode('/', $lineage);

//Store the first part of the string up to the first slash "/"
$patternType = $lineageParts[0];

//Now grab the last part of the pattern key, based on the length of the path we previously exploded.
$patternName = $lineageParts[$length - 1];

//Remove any "_" from pattern Name.
$patternName = ltrim($patternName, '_');

//Remove any potential prefixed numbers or number + dash combos on our Pattern Name.
$patternName = preg_replace('/^[0-9\-]+/', '', $patternName);

//Strip off the pattern path extension (.twig, .mustache, etc)
$patternName = explode('.' . $patternExtension, $patternName);
$patternName = $patternName[0];

//Finally, re-assign $lineage to the default PL pattern key.
$lineage = $patternType . "-" . $patternName;
}

if (PatternData::getOption($lineage)) {

$patternLineages[] = array("lineagePattern" => $lineage,
Expand Down