diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 6be3c3f..765f554 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1900,21 +1900,18 @@ function theme_indentation($variables) {
return $output;
}
+
/**
- * 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());
@@ -1929,7 +1926,8 @@ function theme_container($variables) {
$element['#attributes']['class'][] = 'form-wrapper';
}
- return '
' . $element['#children'] . '
';
+ $variables['children'] = $element['#children'];
+ $variables['attributes'] = $element['#attributes'];
}
/**
@@ -2707,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 9ba4bf4..a618409 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderElementTypesTest.php
@@ -50,7 +50,7 @@ function testContainer() {
'#type' => 'container',
'#markup' => 'foo',
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
// Container with a class.
array(
@@ -62,7 +62,7 @@ function testContainer() {
'class' => 'bar',
),
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
// Container with children.
array(
@@ -73,7 +73,7 @@ function testContainer() {
'#markup' => 'foo',
),
),
- 'expected' => '
foo
',
+ 'expected' => '
foo
' . "\n",
),
);
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 }}