diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index 31c10a7..b55a729 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -148,6 +148,7 @@ public function render($hook, array $variables) { // If an array of hook candidates were passed, use the first one that has an // implementation. + $theme_hook_candidates = is_array($hook) ? $hook : array($hook); if (is_array($hook)) { foreach ($hook as $candidate) { if ($theme_registry->has($candidate)) { @@ -217,6 +218,7 @@ public function render($hook, array $variables) { // Supply original caller info. $variables += array( 'theme_hook_original' => $original_hook, + 'theme_hook_candidates' => $theme_hook_candidates, ); // Set base hook for later use. For example if '#theme' => 'node__article' diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index af5ebe7..c4f5145 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -75,6 +75,14 @@ function twig_render_template($template_file, array $variables) { if ($twig_service->isDebug()) { $output['debug_prefix'] .= "\n\n"; $output['debug_prefix'] .= "\n"; + if (count($variables['theme_hook_candidates']) > 1) { + $candidates = array(); + foreach ($variables['theme_hook_candidates'] as $candidate) { + $prefix = ($variables['theme_hook_original'] == $candidate) ? 'x' : '*'; + $candidates[] = $prefix . ' ' . $candidate; + } + $output['debug_prefix'] .= "\n"; + } // If there are theme suggestions, reverse the array so more specific // suggestions are shown first. if (!empty($variables['theme_hook_suggestions'])) {