1.0.10 • Published 7 years ago

go-json2html v1.0.10

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

go-json2html

DEPRECATED: use go-j2h, instead

Converts objects, arrays and primitives into html. An 'html-object' is an object that has a key that is a valid html tag and is converted into the corresponding html element. This key is referred to as the 'tag-key'. The remaining keys/values of the object are treated as corresponding attributes/values for that html element.

Arrays are interpreted as corresponding sequences of html elements.

Primitives that are values of tag-keys are stringified and appended to the html tag-key.

Any arbitrary html structure can be rendered with arbitrarily deep nesting.

A 'cmd-object' is an object that has one of the command keys: 'empty': empties the html element, but leaves the element itself in place 'rm': removes the content and the element itself 'content': replaces existing content of a non-void html element 'attr': sets an attribute (or replaces with new value, if attribute exists)

Installation

$ npm install go-json2html

Example (test.js)

var dpp = require ('go-json2html').displayPage;

dpp ({
    span: {label: 'test go-json2html'}, 
    style: "border: 1px solid blue;" +
        "border-radius: 4px;" +
        "background-color: #ccffcc;"
});

dpp ({br: 0});
dpp ("plain text");

rendered

1.0.10

7 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago