Added support for in-page twig processing in modular pages

This commit is contained in:
Andy Miller
2015-01-03 16:05:18 -07:00
parent 0f75f6b1e1
commit 5bd79dc072

View File

@@ -176,14 +176,19 @@ 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;
try {
// Get Twig template layout
if ($item->modularTwig()) {
// Process Modular Twig
if ($modular_twig) {
$twig_vars['content'] = $content;
$template = $item->template() . TEMPLATE_EXT;
$output = $local_twig->render($template, $twig_vars);
} else {
$output = $content = $local_twig->render($template, $twig_vars);
}
// Process in-page Twig
if (!$modular_twig || ($modular_twig && $process_twig)) {
$name = '@Page:' . $item->path();
$this->setTemplate($name, $content);
$output = $local_twig->render($name, $twig_vars);
@@ -192,7 +197,6 @@ class Twig
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
return $output;
}