Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-tableify
Create HTML tables from JavaScript Objects
https://github.com/wankdanker/node-tableify
Last synced: 2 months ago
JSON representation
Create HTML tables from JavaScript Objects
- Host: GitHub
- URL: https://github.com/wankdanker/node-tableify
- Owner: wankdanker
- Created: 2014-05-08T19:49:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-11-10T18:06:40.000Z (about 3 years ago)
- Last Synced: 2024-09-16T11:56:08.622Z (4 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 38
- Watchers: 4
- Forks: 20
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-tableify
-------------From any JavaScript object, HTML tables create.
description
-----------Given any Javascript object including Object, Array, Number, Date, null, undefined, primitives,
etc, `tableify` generates HTML tables that represent each object. In the case of Arrays containing
Objects (hash tables), it will generate a table with a header row containing the key names of the
object found in the first element of the array.Every value to be output to the table is processed through `tableify` recursively so objects containing
other objects will result in tables within tables.For each `td` cell that is created, a class is generated based on the `constructor.name` of the value, or
`null` if the value is null.install
-------```bash
npm install tableify
```usage
-----```javascript
var tableify = require('tableify');var html = tableify({
someArrayOfObjects : [
{ a : 1, b : 2, c : 3 }
, { a : 2, b : 3, c : 4 }
, { a : 3, b : 4, c : 5 }
]
, someObject : {
key1 : 'value1'
, someArray : [
'value2'
, 'value3'
, 'value4'
, 'value5'
]
, someArrayOfObjects : [
{ key2 : 123 }
, { key2 : 234 }
, { key2 : 345 }
]
}
});console.log(html);
```command line usage
------------------When installed with `npm install -g tableify` you get the tablify command line utility.
This is a simple command which accepts JSON from stdin and outputs html to stdout. I use
it for emailing json files in a nice format for debugging purposes.The --style option prepends a <style> tag with some default css
```bash
cat datafile.json | tableify --style | mutt -e 'set content_type="text/html"' [email protected]
```license
-------MIT