diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1230,28 +1230,12 @@ } } - // Add the 'empty' row message if available. - if (empty($variables['rows']) && isset($variables['empty'])) { - $header_count = 0; - foreach ($variables['header'] as $header_cell) { - if (is_array($header_cell) && isset($header_cell['colspan'])) { - $header_count += $header_cell['colspan']; - } - else { - $header_count++; - } - } - $variables['rows'][] = array(array( - 'data' => $variables['empty'], - 'colspan' => $header_count, - )); - } - // Build an associative array of responsive classes keyed by column. $responsive_classes = array(); // Format the table header: $ts = array(); + $header_columns = 0; if (!empty($variables['header'])) { $ts = tablesort_init($variables['header']); @@ -1263,11 +1247,18 @@ $responsive_index++; if (!is_array($cell)) { + $header_columns++; $cell_content = $cell; $cell_attributes = new Attribute(); $is_header = TRUE; } else { + if (isset($cell['colspan'])) { + $header_columns += $cell['colspan']; + } + else { + $header_columns++; + } $cell_content = ''; if (isset($cell['data'])) { $cell_content = $cell['data']; @@ -1305,6 +1296,7 @@ $variables['header'][$col_key]['content'] = $cell_content; } } + $variables['header_columns'] = $header_columns; // Rows and footer have the same structure. $sections = array('rows' , 'footer'); diff -u b/core/modules/system/templates/table.html.twig b/core/modules/system/templates/table.html.twig --- b/core/modules/system/templates/table.html.twig +++ b/core/modules/system/templates/table.html.twig @@ -28,12 +28,13 @@ * - attributes: Any HTML attributes, such as "colspan", to apply to the * table cell. * - content: The string to display in the table cell. - * - active_table_sort: A boolean indicating whether the table sort is - * active on cell. + * - active_table_sort: A boolean indicating whether the cell is the active + table sort. * - footer: Table footer rows, in the same format as the rows variable. * - empty: The message to display in an extra row if table does not have * any rows. * - no_striping: A boolean indicating that the row should receive no striping. + * - header_columns: The number of columns in the header. * * @see template_preprocess_table() * @@ -83,22 +84,20 @@ ] %} - {% if empty %} - {% - set empty_classes = [ - 'empty', - 'message', - ] - %} - {% endif %} {% for cell in row.cells %} - <{{ cell.tag }}{{ cell.attributes.addClass(empty_classes) }}> + <{{ cell.tag }}{{ cell.attributes }}> {{- cell.content -}} {% endfor %} {% endfor %} + {% elseif empty %} + + + {{ empty }} + + {% endif %} {% if footer %}