0.1.2 • Published 6 years ago

@dirkdev/json-to-html v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

json-to-html

Simple JSON to HTML converter

Build Status

Installation

Requires at leas Node 6.x Install with npm i @dirkdev/json-to-html

Usage

Default export: function(data, opts?)

  • data: Object representation of the HTML
  • opts: Extra options. Currently none
const json2Html = require('@dirkdev/json-to-html');

const html = json2Html({
  key: 'body',
  style: {
    'background-color': '#9a7ded',
  },
  children: [{
    key: 'ul',
    style: {
      'list-style-type': 'square',
    },
    children: [{
      key: 'li',
      textValue: 'option 1',
    }, {
      key: 'li',
      textValue: 'option 2',
    }, {
      key: 'li',
      textValue: 'option 3',
    }],
  }],
}, null);

res.write(html);

Develop

  • Clone this repo
  • npm install
  • npm run build
  • npm test