From b2f27fbdf298826ff378c5ec1dd7e592056ec071 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Feb 2023 12:55:50 -0700 Subject: [PATCH] cleaner fix for template bug --- system/src/Grav/Common/Twig/Twig.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index e1709d104..a52bb6de8 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -495,17 +495,17 @@ class Twig * the one being passed in * NOTE: Modular pages that are injected should not use this pre-set template as it's usually set at the page level * - * @param PageInterface $page the template name + * @param string $template the template name * @return string the template name */ - public function template(PageInterface $page, string $extension): string + public function template(string $template): string { - $template = $page->template() . $extension; - if ($page->isModule()) { - return $template; - } else { - return $this->template ?? $template; + if (isset($this->template)) { + $template = $this->template; + unset($this->template); } + + return $template; } /** @@ -519,8 +519,7 @@ class Twig $default = $page->isModule() ? 'modular/default' : 'default'; $extension = $format ?: $page->templateFormat(); $twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT; -// $template_file = $template . $twig_extension; - $template_file = $this->template($page, $twig_extension); + $template_file = $this->template($template . $twig_extension); // TODO: no longer needed in Twig 3. /** @var ExistsLoaderInterface $loader */