Added some fallback template handling if not using default .html extension

This commit is contained in:
Andy Miller
2014-12-22 10:53:31 -07:00
parent d32ec013dd
commit ea734567ea

View File

@@ -248,7 +248,16 @@ class Twig
try {
$output = $this->twig->render($template, $twig_vars);
} catch (\Twig_Error_Loader $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
// If loader error, and not .html.twig, try it as fallback
if ($ext != '.html'.TWIG_EXT) {
try {
$output = $this->twig->render($page->template().'.html'.TWIG_EXT, $twig_vars);
} catch (\Twig_Error_Loader $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
} else {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
}
return $output;