All Projects → 8byt → gox

8byt / gox

Licence: MIT license
JSX for Go

Programming Languages

go
31211 projects - #10 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to gox

qlql
No description or website provided.
Stars: ✭ 26 (-84.24%)
Mutual labels:  gopherjs, vecty
vecty-chatapp
Vecty Samples
Stars: ✭ 13 (-92.12%)
Mutual labels:  gopherjs, vecty
Vecty
Vecty lets you build responsive and dynamic web frontends in Go using WebAssembly, competing with modern web frameworks like React & VueJS.
Stars: ✭ 2,161 (+1209.7%)
Mutual labels:  gopherjs, vecty
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (+31.52%)
Mutual labels:  ast
React Monocle
A developer tool to visualize a React application's component hierarchy.
Stars: ✭ 2,440 (+1378.79%)
Mutual labels:  ast
Gengen
A Go source transformation tool for generics
Stars: ✭ 253 (+53.33%)
Mutual labels:  ast
awesome-ruby-ast
A list of awesome tools and libraries which deals with ASTs in Ruby
Stars: ✭ 24 (-85.45%)
Mutual labels:  ast
Tatsu
竜 TatSu generates Python parsers from grammars in a variation of EBNF
Stars: ✭ 198 (+20%)
Mutual labels:  ast
astexplorer-go
No description or website provided.
Stars: ✭ 17 (-89.7%)
Mutual labels:  ast
Gulp Strip Debug
Strip console, alert, and debugger statements from JavaScript code
Stars: ✭ 242 (+46.67%)
Mutual labels:  ast
Tsutils
utility functions for working with typescript's AST
Stars: ✭ 240 (+45.45%)
Mutual labels:  ast
Ast Query
Tentative to a simple JavaScript AST modification library
Stars: ✭ 221 (+33.94%)
Mutual labels:  ast
php2python
Convert PHP code to Python under CGI (beta)
Stars: ✭ 44 (-73.33%)
Mutual labels:  ast
Vermin
Concurrently detect the minimum Python versions needed to run code
Stars: ✭ 218 (+32.12%)
Mutual labels:  ast
sast
Parse CSS, Sass, SCSS, and Less into a unist syntax tree
Stars: ✭ 51 (-69.09%)
Mutual labels:  ast
Hexraystoolbox
Hexrays Toolbox - Find code patterns within the Hexrays AST
Stars: ✭ 202 (+22.42%)
Mutual labels:  ast
html5parser
A super tiny and fast html5 AST parser.
Stars: ✭ 153 (-7.27%)
Mutual labels:  ast
Unified
☔️ interface for parsing, inspecting, transforming, and serializing content through syntax trees
Stars: ✭ 3,036 (+1740%)
Mutual labels:  ast
Cppast.net
CppAst is a .NET library providing a C/C++ parser for header files powered by Clang/libclang with access to the full AST, comments and macros
Stars: ✭ 228 (+38.18%)
Mutual labels:  ast
Esdoc
ESDoc - Good Documentation for JavaScript
Stars: ✭ 2,706 (+1540%)
Mutual labels:  ast

gox

gox is an extension of Go's syntax that let's you write HTML-style tags directly in your source code.

In other words, it's JSX for Go.

Write HTML-style tags directly in your Go source, and have them get transpiled into Vecty components that can be run with GopherJS or WebAssembly.

Okay take a look:

package main

import "github.com/gopherjs/vecty"

type Page struct{
	vecty.Core
}

func (w *Page) Render() vecty.ComponentOrHTML {
	return <body>
		<div class="amazing">
			<h1>gox</h1>
			<span class={"you could put dynamic content here"}/>
			yeah you can do bare words too
		</div>
	</body>
}

func main() {
	vecty.RenderBody(new(Page))
}

Quickstart

git clone github.com/8byt/gox
cd gox/
go run . examples/

go install github.com/hajimehoshi/wasmserve

wasmserve github.com/8byt/gox/examples/readme_1/
google-chrome http://localhost:8080

Why?

Four big reasons:

  • It would be nice to have type safety, but I'm unwilling to write longform Vecty components
  • It would be nice to know how Go parsing works
  • I would like to learn Go by modifying its AST (Danny's reason)
  • I want to write frontend code, but I don't want JS (Eric's reason)

How?

We basically vendored the Go parser/scanner/AST/etc. and just modified it until it fit our needs.

Wot?

Here's a more complicated example portion of a .gox file.

func (p *PageView) renderItemList() vecty.ComponentOrHTML {
	var items vecty.List
	for i, item := range store.Items {
		if (store.Filter == model.Active && item.Completed) || (store.Filter == model.Completed && !item.Completed) {
			continue
		}
		items = append(items, <ItemView Index={i} Item={item} />)
	}

	return <section class="main">
		<input
			id="toggle-all"
			class="toggle-all"
			type="checkbox"
			checked={store.CompletedItemCount() == len(store.Items)}
			onChange={p.onToggleAllCompleted}/>
		<label for="toggle-all">Mark all as complete</label>
		<ul class="todo-list">
			{items}
		</ul>
	</section>
}

from our TodoMVC implementation

alright, I'm convinced, get me started

Wow! Okay I don't think we thought that would happen.

For now, clone this repo, and build it.

Use gox <directory> to convert .gox files into .go files (they stay in the same directory)

GopherJS should take care of the rest, use Vecty's docs and GopherJS's docs to learn more. We use gopherjs serve and things magically get transpiled again.

If you want to make this process better, we'd be happy to consider your ideas/PRs.

Thanks,

Eric and Danny

License

All modifications are MIT

Original Go code is all BSD

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].