Simplified some logic and fixed an issue with system-level process twig logic #1351

This commit is contained in:
Andy Miller
2017-03-19 21:24:46 -06:00
parent 4eebc81808
commit 10a15ef33f
3 changed files with 11 additions and 8 deletions

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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);
}