From 25d45394e7f20f37d4fe9446378c00386cd45129 Mon Sep 17 00:00:00 2001 From: "julien.sibi" Date: Sat, 25 Nov 2017 15:15:14 +0500 Subject: [PATCH] Issue #2913809 by julien.sibi: Ouput drupal_region() function using region's Twig template --- src/TwigExtension.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/TwigExtension.php b/src/TwigExtension.php index 830e431..78db08c 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -93,11 +93,13 @@ class TwigExtension extends \Twig_Extension { * @param string $theme * (Optional) The name of the theme to load the region. If it is not * provided then default theme will be used. + * @param bool $include_template + * (Optional) Render the output using the region's Twig template. * * @return array * A render array to display the region content. */ - public function drupalRegion($region, $theme = NULL) { + public function drupalRegion($region, $theme = NULL, $include_template = FALSE) { $entity_type_manager = \Drupal::entityTypeManager(); $blocks = $entity_type_manager->getStorage('block')->loadByProperties([ 'region' => $region, @@ -122,6 +124,11 @@ class TwigExtension extends \Twig_Extension { } } + if ($include_template) { + $build['#region'] = $region; + $build['#theme_wrappers'] = ['region']; + } + return $build; }