Browse Source

Issue #2913809 by julien.sibi, Chi: Ouput drupal_region() function using region's Twig template.

merge-requests/4/head 8.x-2.0-rc2
Chi 7 years ago
parent
commit
6a4ea3d943
  1. 6
      src/TwigExtension.php
  2. 2
      tests/src/Functional/TwigTweakTest.php

6
src/TwigExtension.php

@ -93,13 +93,11 @@ 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, $include_template = FALSE) {
public function drupalRegion($region, $theme = NULL) {
$entity_type_manager = \Drupal::entityTypeManager();
$blocks = $entity_type_manager->getStorage('block')->loadByProperties([
'region' => $region,
@ -124,7 +122,7 @@ class TwigExtension extends \Twig_Extension {
}
}
if ($include_template) {
if ($build) {
$build['#region'] = $region;
$build['#theme_wrappers'] = ['region'];
}

2
tests/src/Functional/TwigTweakTest.php

@ -75,7 +75,7 @@ class TwigTweakTest extends BrowserTestBase {
$this->assertByXpath($xpath);
// Test region.
$xpath = '//div[@class = "tt-region"]';
$xpath = '//div[@class = "tt-region"]/div[@class = "region region-sidebar-first"]';
$xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]';
$xpath .= '/following-sibling::div[@class="messages messages--warning" and contains(., "Hi!")]';
$xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]';

Loading…
Cancel
Save