README.md 1.3 KB
Newer Older
Zéfling's avatar
Zéfling committed
1
[![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
2
3
4
5
6
7

# json2html

## Installation

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

## Requirements

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

## Demo

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

## Usage

### Examples 

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

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

## Publishing the library

```
ng build json2html --prod
cp *.md dist/json2html
cd dist/json2html
npm publish
```

## Publishing the demo

```
ng build --prod
```

## License

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