Commit f1536191 authored by alexpott's avatar alexpott

Issue #2430981 by Cottser: Unnecessary notices when twig_render_template()...

Issue #2430981 by Cottser: Unnecessary notices when twig_render_template() catches \Twig_Error_Loader exceptions
parent 35f15606
......@@ -51,13 +51,14 @@ function twig_init(Extension $theme) {
function twig_render_template($template_file, array $variables) {
/** @var \Twig_Environment $twig_service */
$twig_service = \Drupal::service('twig');
$output = [
'debug_prefix' => '',
'debug_info' => '',
'rendered_markup' => '',
'debug_suffix' => '',
];
try {
$output = array(
'debug_prefix' => '',
'debug_info' => '',
'rendered_markup' => $twig_service->loadTemplate($template_file)->render($variables),
'debug_suffix' => '',
);
$output['rendered_markup'] = $twig_service->loadTemplate($template_file)->render($variables);
}
catch (\Twig_Error_Loader $e) {
drupal_set_message($e->getMessage(), 'error');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment