addTable method

void addTable(
  1. Iterable<Iterable<SummaryTableCell>> rows
)

Adds an HTML table to the summary buffer.

Implementation

void addTable(Iterable<Iterable<SummaryTableCell>> rows) {
  final tableBody = rows.map((row) {
    final cells = row.map((cell) {
      final tag = cell.header ? 'th' : 'td';

      final attributes = {
        if (cell.columns != null) 'colspan': '${cell.columns}',
        if (cell.rows != null) 'rowspan': '${cell.rows}',
      };

      return _wrap(tag: tag, content: cell.data, attributes: attributes);
    }).join('');

    return _wrap(tag: 'tr', content: cells);
  }).join('');

  addRaw(_wrap(tag: 'table', content: tableBody), addEOL: true);
}