Skip to content

Instantly share code, notes, and snippets.

Last active Dec 25, 2016
What would you like to do?
package main
//go:generate gopherjs build main.go -o js/app.js -m
// +build ignore
import (
// Router is the main reference to the director.js' Router object
type Router struct {
// NewRouter is the contructor, it locates the Router object in the window global object
// and returns its go representation
func NewRouter() *Router {
return &Router{js.Global.Get("Router").New()}
// On is the binding for the javascript router's on method
// it is used for ad-hoc routing
func (r *Router) On(path string, handler func()) {
r.Call("on", path, handler)
// Init is the binding for the javascript router's init function
// path value will be used if '/#/' is not found in the URL.
// (e.g., init('/') will resolve to '/#/', init('foo') will resolve to '/#foo').
func (r *Router) Init(path string) {
r.Call("init", path)
func main() {
router := NewRouter()
router.On("/about", notImplementedYet)
router.On("/contact", notImplementedYet)
router.On("/", notImplementedYet)
var notImplementedYet = func() {
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4V
a+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Custom styles for this template -->
body {
padding-top: 50px;
.starter-template {
padding: 40px 15px;
text-align: center;
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<a class="navbar-brand" href="#">Project name</a>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</div><!--/.nav-collapse -->
<div class="container">
<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p id="main" class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src=""></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<!-- Latest compiled and minified JavaScript -->
<script src="" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7T
xa" crossorigin="anonymous"></script>
<script src="js/director.min.js"></script>
<script src="js/app.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment