simplejsonhtml

SimpleJsonHtml generates HTML from a JSON template and a JSON model

npm install simplejsonhtml
2 downloads in the last week
4 downloads in the last month

SimpleJsonHtml

SimpleJsonHtml generates HTML from a JSON template and a JSON model.

Installation

Via npm on Node:

npm install simplejsonhtml

Usage

Reference in your program:

var sjh = require('simplejsonhtml');

Development

git clone git://github.com/ajlopez/SimpleJsonHtml.git
cd SimpleJsonHtml
npm install
npm test

Samples

sjh.transform("Hello");         // "Hello"
sjh.transform({ h1: "Hello" }); // "<h1>Hello</h1>"
sjh.transform(
    { h1: "Hello ${name}" },
    { name: 'Adam' });          // "<h1>Hello Adam</h1>"
sjh.transform(
    [{ h1: "Hello" }, { h1: "${name}" }],
    { name: 'Adam' });          // "<h1>Hello</h1><h1>Adam</h1>"
sjh.transform(
    { h1: { "class": "main", "html": "Hello ${name}" },
    { name: 'Adam' });          // "<h1 class='main'>Hello Adam</h1>"

If the template is an object, each property is an attribute, except:

  • html: the content

Inception

Inspired by json2html

Contribution

Feel free to file issues and submit pull requests � contributions are welcome<

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.

npm loves you