Giter VIP home page Giter VIP logo

askew's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.