<commit_before>module.exports = function() {
  var generic = function(data, component, $interpolate, componentInfo) {
    var startTable = function(labels) {
      if (!(labels instanceof Array)) {
        labels = [labels]
      }

      var view = '<table class="table table-striped table-bordered"><thead><tr>';

      labels.forEach(function(item) {
        view += '<th>' + item + '</th>';
      });

      view += '</tr></thead>';
      view += '<tbody>';
      return view;
    };

    var makeRow = function(data) {
      var view = ''; // = '<tr>';

      if (typeof data === 'string' || typeof data === 'number') {
        view += '<td>' + data + '</td>';
      }
      else if (data instanceof Array) {
        view += startTable('') + makeRow(data) + finishTable();
      }
      else if (typeof data === 'object') {
        var labels = Object.keys(data);

        view += startTable(labels)
        labels.forEach(function(key) {
          view += makeRow(data[key]);
        });
        view += finishTable();
      }

      return view;
    };

    var finishTable = function() {
      return '</tbody></table>';
    };

    // Create a template
    var view = '';
    var label = component && component.label ? component.label : '';
    view += startTable(label);
    view += makeRow(data);
    view += finishTable();
    return view;
  };

  return {
    generic: generic
  };
};
<commit_msg>Fixing issue where custom components without labels would display empty table headers.<commit_after>module.exports = function() {
  var generic = function(data, component, $interpolate, componentInfo) {
    var startTable = function(labels) {
      if (!(labels instanceof Array)) {
        labels = [labels]
      }

      var view = '<table class="table table-striped table-bordered"><thead><tr>';

      labels.forEach(function(item) {
        view += '<th>' + item + '</th>';
      });

      view += '</tr></thead>';
      view += '<tbody>';
      return view;
    };

    var makeRow = function(data) {
      var view = ''; // = '<tr>';

      if (typeof data === 'string' || typeof data === 'number') {
        view += '<td>' + data + '</td>';
      }
      else if (data instanceof Array) {
        view += startTable('') + makeRow(data) + finishTable();
      }
      else if (typeof data === 'object') {
        var labels = Object.keys(data);

        view += startTable(labels)
        labels.forEach(function(key) {
          view += makeRow(data[key]);
        });
        view += finishTable();
      }

      return view;
    };

    var finishTable = function() {
      return '</tbody></table>';
    };

    // Create a template
    var view = '';
    var label;
    if (!label && component && component.label) {
      label = component.label;
    }
    else if (!label && component && component.key) {
      label = component.key;
    }
    else {
      label = '';
    }
    view += startTable(label);
    view += makeRow(data);
    view += finishTable();
    return view;
  };

  return {
    generic: generic
  };
};

{'fraction_non_alphanumeric': 0.16989176779271892, 'fraction_numerical': 0.0, 'mean_word_length': 2.1573498964803313, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5256288', 'n_tokens_mistral': 881, 'n_tokens_neox': 856, 'n_words': 229}