Skip to content
/ askew Public

code generator & framework for single-page GopherJS/WASM apps

Notifications You must be signed in to change notification settings

flyx/askew

Repository files navigation

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. This readme contains developer information.

How it works

HTML Processing

Askew depends on a forked version of Go's HTML5 parser. This version has been modified to be able to properly process Askew's meta-elements.

The generated code will, on initialization, programmatically create a <template> 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.

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 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. 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

About

code generator & framework for single-page GopherJS/WASM apps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages