https://github.com/unframework/html2hyperscript
Convert legacy HTML to Hyperscript (https://github.com/dominictarr/hyperscript and https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript)
https://github.com/unframework/html2hyperscript
Last synced: 6 months ago
JSON representation
Convert legacy HTML to Hyperscript (https://github.com/dominictarr/hyperscript and https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript)
- Host: GitHub
- URL: https://github.com/unframework/html2hyperscript
- Owner: unframework
- License: other
- Archived: true
- Created: 2015-01-22T03:19:53.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T17:49:46.000Z (over 6 years ago)
- Last Synced: 2024-08-31T16:48:22.027Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 45
- Watchers: 5
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/unframework/html2hyperscript)
# Convert Legacy HTML to Hyperscript
Automatically translate old HTML markup into the new Hyperscript markup embeddable directly inside your component Javascript code.
Use this for hand-converting legacy project source code (e.g. AngularJS templates): care is taken to preserve original whitespace and even comments. For dynamic serving and CI builds check out https://github.com/alexmingoia/jsx-transform instead.
```
npm install -g html2hyperscript
html2hyperscript legacy_markup_file.html > shiny_new_syntax.js
```
See Hyperscript library: https://github.com/dominictarr/hyperscript
Also useful for virtual DOM Hyperscript-like syntax: https://github.com/Matt-Esch/virtual-dom
HTML goes in:
```html
Pandas
Kittens
Hedgehogs
foo
bar
baz
32
45
83
onomatopoeia
schadenfreude
antidisestablishmentarianism
```
Hyperscript-like JS syntax comes out:
```js
h("table.sample-html", [
h("tr", [
h("th", [ "Pandas" ]),
h("th", [ "Kittens" ]),
h("th", [ "Hedgehogs" ])
]),
h("tr", [
h("td", [ "foo" ]),
h("td", [ "bar" ]),
h("td", [ "baz" ])
]),
h("tr", [
h("td", [ "32" ]),
h("td", [ "45" ]),
h("td", [ "83" ])
]),
h("tr", [
h("td", [ "onomatopoeia" ]),
h("td", [ "schadenfreude" ]),
h("td", [ "antidisestablishmentarianism" ])
])
])
```
## TODO
- some tests