go-hyperscript
go-hyperscript copied to clipboard
hyperscript implementation in Go.
go-hyperscript
- Simple hyperscript like script implemented in Go.
- You can use this package in these ways:
- Write HTML using Go function.
- Update existing DOM based on previous VNode tree.
Usage
Write HTML using Go function
func main() {
node := h.H("div", nil,
h.H("h1", nil, h.Text("Example App")),
h.H("strong", nil,
h.H("font", h.Object{"color": "red"}, h.Text("Hello, world!")),
),
...
)
body := js.Global().Get("document").Get("body")
dom.NewRenderer().Render(node, body)
}
Example
- https://syumai.github.io/go-hyperscript/examples/basic/
Update DOM
- Now go-hyperscript provides basic support for reusing and updating existing DOM.
- To use this function, please render multiple times using same renderer.
- Hook state's changes (used in: Simple ToDo list example)
- Use main loop (used in: Counter example)
Examples
Environment
- go 1.13
Development
make build
make test
Author
syumai
License
MIT