diff --git a/core/includes/theme.inc b/core/includes/theme.inc index dd4d409..cb62241 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1041,10 +1041,12 @@ function theme_disable($theme_list) { * @return string * The rendered inline template. */ -function drupal_render_twig_inline(&$variables) { +function drupal_render_twig_inline(&$element) { /** @var \Drupal\Core\Template\TwigEnvironment $environment */ $environment = \Drupal::service('twig'); - return $environment->renderInlineTemplate($variables['template'], $variables['context']); + $markup = $environment->renderInlineTemplate($element['#template'], $element['#context']); + $element['#markup'] = $markup; + return $element; } /** diff --git a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php index 7338000..c4f5c2c 100644 --- a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php +++ b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php @@ -18,21 +18,28 @@ class TwigEnvironmentTest extends KernelTestBase { /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('system'); + + /** * Tests inline templates. */ public function testInlineTemplate() { /** @var \Drupal\Core\Template\TwigEnvironment $environment */ $environment = \Drupal::service('twig'); $this->assertEqual($environment->renderInlineTemplate('test-no-context'), 'test-no-context'); - $this->assertEqual($environment->renderInlineTemplate('test-with-context {{lama}}', array('lama' => 'muuh')), 'test-with-context muuh'); + $this->assertEqual($environment->renderInlineTemplate('test-with-context {{ lama }}', array('lama' => 'muuh')), 'test-with-context muuh'); $element = array(); $element['test'] = array( '#type' => 'twig_inline', - '#template' => 'test-with-context {{lama}}', + '#template' => 'test-with-context {{ lama }}', '#context' => array('lama' => 'muuh'), ); - $this->assertEqual($environment->renderInlineTemplate('test-with-context {{lama}}', array('lama' => 'muuh')), 'test-with-context muuh'); + $this->assertEqual(drupal_render($element), 'test-with-context muuh'); } } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 9af0e0f..6483578 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -305,7 +305,7 @@ function system_element_info() { '#title' => '', ); $types['twig_inline'] = array( - '#pre_render' => 'drupal_render_twig_inline', + '#pre_render' => array('drupal_render_twig_inline'), '#template' => '', '#context' => array(), );