Array to Html
Convert an array of objects to a simple html table, list or DOMElement.
Install 

$ npm i array-to-html
Use
Array to Table
Sample
const { arrayToTable } = require('array-to-html');
const tableArray = [
{
Name: 'Jack',
Age: 40,
},
{
Name: 'Maria',
Age: 35,
},
];
const tableHtml = arrayToTable(tableArray);
console.log(tableHtml);
Output
Options
Options | Type | Description |
---|
minify | Boolean | Compress HTML, remove spaces and breaks |
fake_style | Boolean | Insert styles |
columns_size | Numeric Array | Percent array [25, 25, 0, 50] |
header | Array | Header property, label, width |
const tableArray = [ ... ];
const options = {
minify: true,
fake_style: true,
columns_size: [70, 30],
header: [
{
property: 'Name',
label: 'N-A-M-E',
width: 70,
}
]
}
const tableHtml = arrayToTable(tableArray, options);
ToDo
- Table DOMElement
- Array to List
License
The MIT License.
Author