mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Merge remote-tracking branch 'origin/1.7' into 1.7
# Conflicts: # composer.lock
This commit is contained in:
commit
a571f42e1b
|
|
@ -17,6 +17,7 @@
|
|||
* Updated vendor libraries
|
||||
* Use `Symfony EventDispatcher` directly and not rockettheme/toolbox wrapper
|
||||
1. [](#bugfix)
|
||||
* Fixed exception caused by missing template type based on `Accept:` header [#2705](https://github.com/getgrav/grav/issues/2705)
|
||||
* Fixed `Page::untranslatedLanguages()` not being symmetrical to `Page::translatedLanguages()`
|
||||
* Fixed `Flex Pages` not calling `onPageProcessed` event when cached
|
||||
* Fixed phpstan issues in Framework up to level 7
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
"donatj/phpuseragentparser": "~0.10",
|
||||
"pimple/pimple": "~3.2",
|
||||
"rockettheme/toolbox": "~1.4",
|
||||
"maximebf/debugbar": "~1.15",
|
||||
"maximebf/debugbar": "~1.0",
|
||||
"league/climate": "^3.4",
|
||||
"antoligy/dom-string-iterators": "^1.0",
|
||||
"miljar/php-exif": "^0.6.4",
|
||||
|
|
|
|||
|
|
@ -290,17 +290,15 @@ class Twig
|
|||
$twig_vars['page'] = $item;
|
||||
$twig_vars['media'] = $item->media();
|
||||
$twig_vars['header'] = $item->header();
|
||||
|
||||
$local_twig = clone $this->twig;
|
||||
|
||||
$output = '';
|
||||
|
||||
try {
|
||||
// Process Modular Twig
|
||||
if ($item->modularTwig()) {
|
||||
$twig_vars['content'] = $content;
|
||||
$extension = $item->templateFormat();
|
||||
$extension = $extension ? ".{$extension}.twig" : TEMPLATE_EXT;
|
||||
$template = $item->template() . $extension;
|
||||
$template = $this->getPageTwigTemplate($item);
|
||||
$output = $content = $local_twig->render($template, $twig_vars);
|
||||
}
|
||||
|
||||
|
|
@ -310,8 +308,9 @@ class Twig
|
|||
$this->setTemplate($name, $content);
|
||||
$output = $local_twig->render($name, $twig_vars);
|
||||
}
|
||||
|
||||
} catch (LoaderError $e) {
|
||||
throw new \RuntimeException($e->getRawMessage(), 404, $e);
|
||||
throw new \RuntimeException($e->getRawMessage(), 400, $e);
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
@ -394,7 +393,6 @@ class Twig
|
|||
$twig_vars['header'] = $page->header();
|
||||
$twig_vars['media'] = $page->media();
|
||||
$twig_vars['content'] = $content;
|
||||
$ext = '.' . ($format ?: 'html') . TWIG_EXT;
|
||||
|
||||
// determine if params are set, if so disable twig cache
|
||||
$params = $this->grav['uri']->params(null, true);
|
||||
|
|
@ -403,23 +401,13 @@ class Twig
|
|||
}
|
||||
|
||||
// Get Twig template layout
|
||||
$template = $this->template($page->template() . $ext);
|
||||
$template = $this->getPageTwigTemplate($page, $format);
|
||||
|
||||
try {
|
||||
$output = $this->twig->render($template, $vars + $twig_vars);
|
||||
} catch (LoaderError $e) {
|
||||
$error_msg = $e->getMessage();
|
||||
// Try html version of this template if initial template was NOT html
|
||||
if ($ext !== '.html' . TWIG_EXT) {
|
||||
try {
|
||||
$page->templateFormat('html');
|
||||
$output = $this->twig->render($page->template() . '.html' . TWIG_EXT, $vars + $twig_vars);
|
||||
} catch (LoaderError $e) {
|
||||
throw new \RuntimeException($error_msg, 400, $e);
|
||||
}
|
||||
} else {
|
||||
throw new \RuntimeException($error_msg, 400, $e);
|
||||
}
|
||||
throw new \RuntimeException($error_msg, 400, $e);
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
@ -460,6 +448,22 @@ class Twig
|
|||
return $this->template ?? $template;
|
||||
}
|
||||
|
||||
public function getPageTwigTemplate($page, $format = null)
|
||||
{
|
||||
$template = $page->template();
|
||||
$extension = $format ?: $page->templateFormat();
|
||||
$twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT;
|
||||
$template_file = $this->template($page->template() . $twig_extension);
|
||||
|
||||
if ($this->twig->getLoader()->exists($template_file)) {
|
||||
return $template_file;
|
||||
} else {
|
||||
// Default to HTML
|
||||
$page->templateFormat('html');
|
||||
return $template . TEMPLATE_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the autoescape setting
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user