From 10a15ef33f384da86b630db118dbe2bf10364925 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 19 Mar 2017 21:24:46 -0600 Subject: [PATCH] Simplified some logic and fixed an issue with system-level process twig logic #1351 --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Page/Page.php | 4 ++-- system/src/Grav/Common/Twig/Twig.php | 9 +++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73c4febf5..e345ca4f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.0-rc.3 +## 03/xx/2017 + +1. [](#bugfix) + * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) + # v1.2.0-rc.2 ## 03/17/2017 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index c5adb80ef..d6637f753 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -575,7 +575,8 @@ class Page $process_markdown = $this->shouldProcess('markdown'); - $process_twig = $this->shouldProcess('twig'); + $process_twig = $this->shouldProcess('twig') || $this->modularTwig() ; + $cache_enable = isset($this->header->cache_enable) ? $this->header->cache_enable : $config->get('system.cache.enabled', true); $twig_first = isset($this->header->twig_first) ? $this->header->twig_first : $config->get('system.pages.twig_first', @@ -2036,7 +2037,6 @@ class Page if ($var !== null) { $this->modular_twig = (bool)$var; if ($var) { - $this->process['twig'] = true; $this->visible(false); // some routable logic if (empty($this->header->routable)) { diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 9ef9e3e6d..4ca45c7f6 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -229,25 +229,22 @@ class Twig $twig_vars['header'] = $item->header(); $local_twig = clone($this->twig); - $modular_twig = $item->modularTwig(); - $process_twig = isset($item->header()->process['twig']) ? $item->header()->process['twig'] : false; - - $output = ''; try { // Process Modular Twig - if ($modular_twig) { + if ($item->modularTwig()) { $twig_vars['content'] = $content; $template = $item->template() . TEMPLATE_EXT; $output = $content = $local_twig->render($template, $twig_vars); } // Process in-page Twig - if (!$modular_twig || ($modular_twig && $process_twig)) { + if ($item->shouldProcess('twig')) { $name = '@Page:' . $item->path(); $this->setTemplate($name, $content); $output = $local_twig->render($name, $twig_vars); } + } catch (\Twig_Error_Loader $e) { throw new \RuntimeException($e->getRawMessage(), 404, $e); }