Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syumai/go-hyperscript
hyperscript implementation in Go.
https://github.com/syumai/go-hyperscript
golang hyperscript webassembly
Last synced: 4 months ago
JSON representation
hyperscript implementation in Go.
- Host: GitHub
- URL: https://github.com/syumai/go-hyperscript
- Owner: syumai
- License: mit
- Created: 2018-09-02T17:51:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-16T03:31:38.000Z (about 4 years ago)
- Last Synced: 2024-06-20T11:07:12.287Z (7 months ago)
- Topics: golang, hyperscript, webassembly
- Language: Go
- Homepage:
- Size: 4.26 MB
- Stars: 18
- Watchers: 4
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-hyperscript
- Simple [hyperscript](https://github.com/hyperhype/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
```go
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/
- [Code](https://github.com/syumai/go-hyperscript/tree/master/examples/basic/main.go)### 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](https://syumai.github.io/go-hyperscript/examples/simpletodo/))
- Use main loop (used in: [Counter example](https://syumai.github.io/go-hyperscript/examples/counter/))#### Examples
- [Simple ToDo list example](https://syumai.github.io/go-hyperscript/examples/simpletodo/)
- [Code](https://github.com/syumai/go-hyperscript/tree/master/examples/simpletodo/main.go)
- [Counter example](https://syumai.github.io/go-hyperscript/examples/counter/)
- [Code](https://github.com/syumai/go-hyperscript/tree/master/examples/counter/main.go)## Environment
- go 1.13
## Development
```console
make build
make test
```## Author
syumai
## License
MIT