simplejsonhtml

SimpleJsonHtml generates HTML from a JSON template and a JSON model

SimpleJsonHtml

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

Via npm on Node:

npm install simplejsonhtml

Reference in your program:

var sjh = require('simplejsonhtml');
git clone git://github.com/ajlopez/SimpleJsonHtml.git
cd SimpleJsonHtml
npm install
npm test
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

Inspired by json2html

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.