array-to-html
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

Array to Html

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

Install

NPM

$ npm i array-to-html

Use

Array to Table

Sample

const { arrayToTable } = require('array-to-html');

// array collection
const tableArray = [
  {
    Name: 'Jack',
    Age: 40,
  },
  {
    Name: 'Maria',
    Age: 35,
  },  
];

// the magic
const tableHtml = arrayToTable(tableArray);
// output
console.log(tableHtml);

Output

Name Age
Jack 40
Maria 35

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
// array collection
const tableArray = [ ... ];

// options
const options = {
  minify: true, 
  fake_style: true,
  columns_size: [70, 30], // 70%. 30% (two columns)
  header: [
    {
      property: 'Name',
      label: 'N-A-M-E',
      width: 70, // 70%
    }
  ]
}
// the magic
const tableHtml = arrayToTable(tableArray, options);

ToDo

  • Table DOMElement
  • Array to List

License

The MIT License.

Author

Natan Cabral
natancabral@hotmail.com
https://github.com/natancabral/

Package Sidebar

Install

npm i array-to-html

Weekly Downloads

34

Version

0.0.14

License

MIT

Unpacked Size

21.9 kB

Total Files

11

Last publish

Collaborators

  • natancabral