Skip to content

Commit

Permalink
fix: wrong template path when using latte includes
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jul 24, 2023
1 parent 959f797 commit f2277e7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion RockFrontend.module.php
Expand Up @@ -486,7 +486,6 @@ public function alfred($page = null, $options = [])
]);
$opt->setArray($options);


// add quick-add-icons for rockpagebuilder
if ($rpb = $this->wire->modules->get("RockPageBuilder")) {
/** @var RockPageBuilder $rpb */
Expand Down Expand Up @@ -929,6 +928,21 @@ public function getTplPath()
$paths = $this->wire->config->paths;
foreach ($trace as $step) {
$file = $step['file'];

// first check for latte cache files
// these files are .php files compiled from the original .latte file
// we use these files because that also works when using latte "include" statements
if (str_contains($file, ".latte--") and str_ends_with($file, ".php")) {
// the template file seems to be a latte file
// get source file from the cached content
$content = file_get_contents($file);
$pattern = '/\/\*\* source: (.+?) \*\//s';
if (preg_match($pattern, $content, $matches)) {
$sourceFile = $matches[1];
return $sourceFile;
}
}

$skip = [
$paths->cache,
$paths($this),
Expand Down

0 comments on commit f2277e7

Please sign in to comment.