parse-hyperscript
Parse hyperscript-like syntax for creating dom or virtual-dom elements.
This layer exists to build a hyperscript-like DSL for any kind of dom/virtual-dom creation library.
Installation
> npm install parse-hyperscript
Example
const parse = const node = 'p.some-class' id: 'test' style: 'background-color: red;' 'text node' const ast = console
Returns:
tag: 'p' attrs: id: 'test' class: 'some-class' style: 'background-color: red;' children: 'text-node'
Creating react nodes
The following is an example implementation with React to demonstrate how you might integrate it with your view library:
const createElement = { const tag attrs children = return } const node = // -> ReactElement
Implementations
- preact-hyperscript - For Preact
- create-dom-tree - For the raw DOM
❤️ Built one of your own? Add it!
Tests
npm test