simplejsonhtml

0.0.1alph • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i simplejsonhtml

      Weekly Downloads

      0

      Version

      0.0.1alph

      License

      none

      Last publish

      Collaborators

      • ajlopez