Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/we-lib/obj-html
Parse js obj model to html
https://github.com/we-lib/obj-html
Last synced: 23 days ago
JSON representation
Parse js obj model to html
- Host: GitHub
- URL: https://github.com/we-lib/obj-html
- Owner: we-lib
- Created: 2014-09-07T13:48:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-07T13:48:32.000Z (over 10 years ago)
- Last Synced: 2024-08-09T15:52:39.332Z (5 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# obj-html
Parse js obj model to html
## Usage
Expected:
```html
My Page
Bla bla bla..
```
Parsing:
```js
var parseHtml = require('obj-html')
var html = parseHtml(htmlObj)
console.log(html)
```Source:
```js
[
{
'tag': '!doctype',
'attrs': {
'html': true
}
},
{
'tag': 'html',
'children': [
{
'tag': 'head',
'children': [
{
'tag': 'meta',
'attrs': {
'charset': 'utf-8'
}
},
{
'tag': 'title',
'children': [
'My Page'
]
},
{
'tag': 'link',
'attrs': [
'rel': 'stylesheet',
'href': 'style.css'
]
}
]
},
{
'tag': 'body',
'children': [
{
'tag': 'div',
'attrs': {
'id': 'box'
}
},
{
'tag': 'p',
'children': [
'Bla bla bla..',
{
'tag': 'i',
'attrs': {
'class': 'icon foo'
}
}
]
}
]
}
]
}
]
```