trtd

0.0.1 • Public • Published

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 or Object or undefined
    • Rendered as head.
    • If undefined, only render
  • body
    • Array or Object
    • Render as body.
  • opt
    • Object
    • pretty (default true) : pretty print flag
    • indent_size (default 2) : 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)

Readme

Keywords

none

Package Sidebar

Install

npm i trtd

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • suisho
  • inuscript
  • terrierscript