diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index e91ecf2..7df6286 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1889,20 +1889,16 @@ function theme_indentation($variables) {
}
/**
- * Returns HTML to wrap child elements in a container.
+ * Prepares variables for container templates.
*
- * Used for grouped form items. Can also be used as a #theme_wrapper for any
- * renderable element, to surround it with a
and add attributes such as
- * classes or an HTML id.
+ * Default template: container.html.twig.
*
- * @param $variables
+ * @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #id, #attributes, #children.
- *
- * @ingroup themeable
*/
-function theme_container($variables) {
+function template_preprocess_container(&$variables) {
$element = $variables['element'];
// Ensure #attributes is set.
$element += array('#attributes' => array());
@@ -1917,7 +1913,8 @@ function theme_container($variables) {
$element['#attributes']['class'][] = 'form-wrapper';
}
- return '
' . $element['#children'] . '
';
+ $variables['children'] = $element['#children'];
+ $variables['attributes'] = $element['#attributes'];
}
/**
@@ -2708,6 +2705,7 @@ function drupal_common_theme() {
),
'container' => array(
'render element' => 'element',
+ 'template' => 'container',
),
);
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
index 56b8aee..788d864 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
@@ -84,7 +84,7 @@ function testContainer() {
'#type' => 'container',
'#markup' => 'foo',
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
// Container with a class.
array(
@@ -96,7 +96,7 @@ function testContainer() {
'class' => 'bar',
),
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
// Container with children.
array(
@@ -107,7 +107,7 @@ function testContainer() {
'#markup' => 'foo',
),
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index b1d4ca9..fefd8e0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -91,7 +91,7 @@ function testDrupalRenderBasics() {
'#theme_wrappers' => array('container'),
'#attributes' => array('class' => 'baz'),
),
- 'expected' => '
foobar
',
+ 'expected' => '
foobar
' . "\n",
),
// Test that #theme_wrappers can disambiguate element attributes shared
// with rendering methods that build #children by using the alternate
@@ -109,7 +109,7 @@ function testDrupalRenderBasics() {
'#href' => 'http://drupal.org',
'#title' => 'bar',
),
- 'expected' => '
',
+ 'expected' => '
' . "\n",
),
// Test that #theme_wrappers can disambiguate element attributes when the
// "base" attribute is not set for #theme.
@@ -125,7 +125,7 @@ function testDrupalRenderBasics() {
),
),
),
- 'expected' => '
',
+ 'expected' => '
' . "\n",
),
// Two 'container' #theme_wrappers, one using the "base" attributes and
// one using an override.
@@ -140,7 +140,7 @@ function testDrupalRenderBasics() {
'container',
),
),
- 'expected' => '
',
+ 'expected' => '
' . "\n",
),
// Array syntax theme hook suggestion in #theme_wrappers.
array(
@@ -149,7 +149,7 @@ function testDrupalRenderBasics() {
'#theme_wrappers' => array(array('container')),
'#attributes' => array('class' => 'foo'),
),
- 'expected' => '
',
+ 'expected' => '
' . "\n",
),
// Test handling of #markup as a fallback for #theme hooks.
diff --git a/core/modules/system/templates/container.html.twig b/core/modules/system/templates/container.html.twig
new file mode 100644
index 0000000..933a201
--- /dev/null
+++ b/core/modules/system/templates/container.html.twig
@@ -0,0 +1,15 @@
+{#
+/**
+ * @file
+ * Default theme implementation of a container used to wrap child elements.
+ *
+ * Available variables:
+ * - attributes: HTML attributes for the containing element.
+ * - children: The rendered child elements of the container.
+ *
+ * @see template_preprocess_container()
+ *
+ * @ingroup themeable
+ */
+#}
+
{{ children }}