go-template-turbo-sample

command module
v0.0.0-...-8a30ce1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2021 License: Unlicense Imports: 6 Imported by: 0

README

go-template-turbo-sample

This is a sample project to show how to use Go (templates) with Turbo.

This project uses:

  • Go, a programming language that makes it easy to build simple, reliable, and efficient software.
  • html/template, a html templating library included in the stdlib of Go
  • Echo, a Go web framework
  • Turbo, part of Hotwire a new approach from Basecamp for writing modern web applications without much JavaScript
  • tailwindcss, makes HTML look nice
  • webpack, for packing JS and CSS into single files, with minimization enabled, setup to extract CSS to a seperate file
  • Air, for hot reloading Go code and templates on change.

Setup

You need to have go and npm installed.

Then run:

go get -u github.com/cosmtrek/air
git clone https://github.com/lu4p/go-template-turbo-sample.git
cd templates-turbo-sample
npm install
npm run dev

After the above just run air, to start the webapp with hot reloading.

Note: The generated dist/main.css file is rather large now at ~6MB, but don't worry this is only because every possible class of tailwind is included (there a many), once you build for production only ~4KB of CSS is left.

If you want to also rebuild the JS and CSS on change run npm run watch in a separate terminal session.

To build for production run npm run prod and go build.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL