README.md 1.36 KB
Newer Older
Zéfling's avatar
Zéfling committed
1
2
# json2html

Zéfling's avatar
Zéfling committed
3
4
5
6
Generation of an HTML plain text from a Json structure with several setting options.

[![npm version](https://badge.fury.io/js/json2html-lib.svg)](https://badge.fury.io/js/json2html-lib) [![Downloads](https://img.shields.io/npm/dm/json2html-lib.svg)](https://www.npmjs.com/package/json2html-lib) [![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://git.ikilote.net/angular/json2html/raw/master/LICENSE)

Zéfling's avatar
Zéfling committed
7
8
9
## Installation

```
Zéfling's avatar
Zéfling committed
10
npm i json2html-lib --save
Zéfling's avatar
Zéfling committed
11
12
13
14
15
```

## Requirements

Only for demo:
Zéfling's avatar
Zéfling committed
16
- Angular 10.0.0 and more
Zéfling's avatar
Zéfling committed
17
18
19
20
21
22
23
24
25
26

## Demo

[See a live demonstation](http://test.ikilote.net/json2html-demo/)

## Usage

### Examples 

```typescript
Zéfling's avatar
Zéfling committed
27
import { Json2html } from 'json2html-lib';
Zéfling's avatar
Zéfling committed
28
29
30
31

console.log(new Json2html({
      tag: 'div',
      attrs: { id: 'test1', class: 'testclasse' },
32
33
      body: [
        'test',
Zéfling's avatar
Zéfling committed
34
35
36
37
38
39
        {
          tag: 'div',
          attrs: { id: 'test2', class: 'foobar' },
          body: 'test'
        }
      ]
40
41
42
43
44
45
46
47
48
49
50
    }, { formatting: 'multiline' }).toString());
/*
<div id="test1"
     class="testclasse">
    test
    <div id="test2"
         class="foobar">
        test
    </div>
</div>
*/
Zéfling's avatar
Zéfling committed
51
52
53
54
55
```

## Publishing the library

```
Zéfling's avatar
Zéfling committed
56
npm run build:lib
Zéfling's avatar
Zéfling committed
57
58
59
60
61
62
63
cd dist/json2html
npm publish
```

## Publishing the demo

```
Zéfling's avatar
Zéfling committed
64
npm run build:demo
Zéfling's avatar
Zéfling committed
65
66
67
68
69
```

## License

This module is released under the permissive MIT license. Your contributions are always welcome.