trtd
v0.0.1
Published
Render Html table from object
Downloads
4
Readme
trtd
Render Html table from object
install
npm install trtd
usage
var trtd = require("trtd")
var html = trtd({ head : "object"}, { body : "object"})
API
trtd( head, body , [ opt ] )
head
Array
orObject
orundefined
- Rendered as head.
- If
undefined
, only render
body
Array
orObject
- Render as body.
opt
Object
pretty
(defaulttrue
) : pretty print flagindent_size
(default2
) : html indet size
Example
<table>
<tr>
<th>parameter</th>
<th>description</th>
</tr>
<tr>
<td>foo</td>
<td>hogehoge</td>
</tr>
<tr>
<td>baz</td>
<td>fugafuga</td>
</tr>
</table>
If you want get above html, can these parameters.
- head = object, body = object
var head = {
param: 'parameter',
desc: 'description'
}
var body = {
foo: {
desc: 'hogehoge'
},
baz: {
desc: 'fugafuga'
}
}
trtd(head, body)
- head = object, body = array
var head = {
param: 'parameter',
desc: 'description'
}
var body =[
{
param: 'foo',
desc: 'hogehoge'
},
{
desc: 'fugafuga',
param: 'baz'
}
]
trtd(head, body)
- head = array , body = array
var head = [
'parameter',
'description'
]
var body =[
{
parameter: 'foo',
description: 'hogehoge'
},
{
description: 'fugafuga',
parameter: 'baz'
}
]
trtd(head, body)