mirror of
https://github.com/getgrav/grav.git
synced 2026-02-26 16:41:34 +01:00
Added default templates in Grav itself
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
# v1.7.0-rc.17
|
||||
## mm/dd/2020
|
||||
|
||||
1. [](#improved)
|
||||
* Fall back through various templates scenarios if they don't exist in theme to avoid unhelpful error.
|
||||
* Added default templates for `external.html.twig`, `default.html.twig`, and `modular.html.twig`
|
||||
1. [](#bugfix)
|
||||
* Fixed `Security::sanitizeSVG()` creating an empty file if SVG file cannot be parsed
|
||||
* Fixed infinite loop in blueprints with `extend@` to a parent stream
|
||||
|
||||
@@ -445,14 +445,31 @@ class Twig
|
||||
$twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT;
|
||||
$template_file = $this->template($page->template() . $twig_extension);
|
||||
|
||||
$page_template = null;
|
||||
|
||||
$loader = $this->twig->getLoader();
|
||||
if ($loader instanceof ExistsLoaderInterface && $loader->exists($template_file)) {
|
||||
return $template_file;
|
||||
if ($loader instanceof ExistsLoaderInterface ) {
|
||||
|
||||
if ($loader->exists($template_file)) {
|
||||
$page_template = $template_file;
|
||||
} else {
|
||||
// Try with template + html.twig
|
||||
if ($twig_extension !== TEMPLATE_EXT && $loader->exists($template . TEMPLATE_EXT)) {
|
||||
$page_template = $template . TEMPLATE_EXT;
|
||||
// Try with default and original extension
|
||||
} elseif ($loader->exists('default' . $twig_extension)) {
|
||||
$page_template = 'default' . $twig_extension;
|
||||
// Else try default + default extension
|
||||
} elseif (!$page->modular() && $loader->exists('default' . TEMPLATE_EXT)) {
|
||||
$page_template = 'default' . TEMPLATE_EXT;
|
||||
} else {
|
||||
$page_template = 'modular/default' . TEMPLATE_EXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Default to HTML
|
||||
$page->templateFormat('html');
|
||||
return $template . TEMPLATE_EXT;
|
||||
return $page_template;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
4
system/templates/default.html.twig
Normal file
4
system/templates/default.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{# Default output if no theme #}
|
||||
<h3 style="color:red">ERROR: <code>{{ page.template() ~'.'~ page.templateFormat() ~".twig" }}</code> template not found for page: <code>{{ page.route() }}</code></h3>
|
||||
<h1>{{ page.title() }}</h1>
|
||||
{{ page.content()|raw }}
|
||||
1
system/templates/external.html.twig
Normal file
1
system/templates/external.html.twig
Normal file
@@ -0,0 +1 @@
|
||||
{# Default external template #}
|
||||
4
system/templates/modular/default.html.twig
Normal file
4
system/templates/modular/default.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{# Default output if no theme #}
|
||||
<h3 style="color:red">ERROR: <code>{{ page.template() ~'.'~ page.templateFormat() ~".twig" }}</code> template not found for page: <code>{{ page.route() }}</code></h3>
|
||||
<h1>{{ page.title() }}</h1>
|
||||
{{ page.content()|raw }}
|
||||
Reference in New Issue
Block a user