(name, properties, data)
| 95 | * `data`. |
| 96 | */ |
| 97 | const renderTable = (name, properties, data) => { |
| 98 | if (data === undefined || data.length === 0) { |
| 99 | return ''; |
| 100 | } |
| 101 | return ` |
| 102 | ${name ? `<h3>${name}</h3>` : ''} |
| 103 | <table> |
| 104 | <tr> |
| 105 | ${properties |
| 106 | .map( |
| 107 | (p) => |
| 108 | `<th>${capitalize( |
| 109 | (Array.isArray(p) ? p[0] : p).split('.')[0] |
| 110 | )}</th>` |
| 111 | ) |
| 112 | .join('')} |
| 113 | </tr> |
| 114 | ${data |
| 115 | .map( |
| 116 | (i) => ` |
| 117 | <tr> |
| 118 | ${properties.map((p) => `<td>${get(i, p)}</td>`).join('')} |
| 119 | </tr> |
| 120 | ` |
| 121 | ) |
| 122 | .join('')} |
| 123 | </table> |
| 124 | `; |
| 125 | }; |
| 126 | |
| 127 | const capitalize = (s) => s[0].toUpperCase() + s.substring(1); |
no test coverage detected