mirror of
https://github.com/getgrav/grav.git
synced 2026-05-29 23:53:32 +02:00
Added support for in-page twig processing in modular pages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user