Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flyx/askew
code generator & framework for single-page GopherJS/WASM apps
https://github.com/flyx/askew
declarative-ui gopherjs wasm
Last synced: 10 days ago
JSON representation
code generator & framework for single-page GopherJS/WASM apps
- Host: GitHub
- URL: https://github.com/flyx/askew
- Owner: flyx
- Created: 2020-05-22T21:00:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T13:30:09.000Z (almost 3 years ago)
- Last Synced: 2024-10-25T19:43:27.838Z (about 2 months ago)
- Topics: declarative-ui, gopherjs, wasm
- Language: Go
- Homepage: https://flyx.github.io/askew
- Size: 636 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
Askew
A minimal framework for writing dynamic websites in pure Go
Askew defines a small meta-language based on HTML to define UI components you can use to build client-side web applications.
Its two purposes are to enable you to declaratively define your UI, and to provide glue between the DOM API and your Go code.Askew provides a JavaScript backend, where the Go code is compiled to JavaScript via GopherJS, and a WASM backend, where the Go code is compiled to WebAssembly.
The WebAssembly depends on `wasm_exec.js`, the runtime for the WASM generated by the Go compiler.
Other than that, no JavaScript libraries are used.Askew's user documentation is available [here](https://flyx.github.io/askew).
This readme contains developer information.## How it works
### HTML Processing
Askew depends on a [forked version](https://github.com/flyx/net) of Go's [HTML5 parser](https://pkg.go.dev/golang.org/x/net/html).
This version has been modified to be able to properly process Askew's meta-elements.The generated code will, on initialization, programmatically create a `` element for each component type, and base component instantiations on copies of that template.
Hooks on certain element, e.g. for binding or event capturing, are stored as paths into the DOM content of the template.
These paths are used on instantiation to identify the elements that need to get hooked.This was considered a quick and robust way to implement the HTML meta processing, though it might not be the most elegant or performant one.
The biggest problem with using the HTML5 parser is that you can't get line or column numbers to do error reporting because the parser [does not track those](https://github.com/golang/go/issues/34302).### Custom Syntax Processing
The custom syntax used in Askew's meta-elements and -attributes is parsed via a PEG grammar.
This grammar is defined in `parsers/grammar.peg`.
It uses [pointlander/peg](https://github.com/pointlander/peg) to generate Go code; you can invoke it with `go generate` in the `parsers` directory.### Go Code Generation
Go code is generated via `text/template`.
`goimports` is used on the generated code to format it properly and remove unused imports.## Documentation
The documentation pages are generated via [piranha/gostatic](github.com/piranha/gostatic).
The `site` directory contains the sources, from which the pages can be generated with `make`.
The resulting HTML files are moved into the `gh-pages` branch.## License
MIT