All Projects → jmcfarlane → golang-templates-example

jmcfarlane / golang-templates-example

Licence: other
A simple Golang templates example

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to golang-templates-example

demo-ipfs-id-qr-codes
Generates a QR Code of your IPNS URL and Public Key
Stars: ✭ 21 (-36.36%)
Mutual labels:  example
react-native-firebase-firestore-crud-example
React Native Firebase Tutorial: Build CRUD Firestore App
Stars: ✭ 24 (-27.27%)
Mutual labels:  example
nextjs-mdx-blog-example
Blog example using Next.js and MDX (Markdown + React)
Stars: ✭ 63 (+90.91%)
Mutual labels:  example
Examples Qt
Shows how to use Qt widgets only by programming code (c++17).
Stars: ✭ 38 (+15.15%)
Mutual labels:  example
supabase flutter
Using Supabase in Flutter
Stars: ✭ 38 (+15.15%)
Mutual labels:  example
example-typescript-package
Example TypeScript Package ready to be published on npm & Tutorial / Instruction / Workflow for 2021
Stars: ✭ 71 (+115.15%)
Mutual labels:  example
controller-rs
A kubernetes example controller
Stars: ✭ 134 (+306.06%)
Mutual labels:  example
UnityVolumeRendering
A simple example of Volume Rendering for Unity.
Stars: ✭ 139 (+321.21%)
Mutual labels:  example
Dagger2-Sample
Very simple example to use Dagger 2
Stars: ✭ 13 (-60.61%)
Mutual labels:  example
awesome-flutter-ui
10+ flutter(android, ios) UI design examples ⚡ - login, books, profile, food order, movie streaming, walkthrough, widgets
Stars: ✭ 848 (+2469.7%)
Mutual labels:  example
cloudopt-next-example
Example of cloudopt-next
Stars: ✭ 22 (-33.33%)
Mutual labels:  example
javascript-starter
A few simple examples to help you get started using the Clarifai Javascript client and API
Stars: ✭ 18 (-45.45%)
Mutual labels:  example
play-scala-seed.g8
Play Scala Seed Template: run "sbt new playframework/play-scala-seed.g8"
Stars: ✭ 66 (+100%)
Mutual labels:  example
LMIC-node
LMIC-node | One example to rule them all. LMIC-node is an example LoRaWAN application for a node that can be used with The Things Network. It demonstrates how to send uplink messages, how to receive downlink messages, how to implement a downlink command and it provides useful status information. With LMIC-node it is easy to get a working node qu…
Stars: ✭ 108 (+227.27%)
Mutual labels:  example
play-java-rest-api-example
REST API using Play in Java
Stars: ✭ 44 (+33.33%)
Mutual labels:  example
interop
Python/C/Go/Rust/Haskell interop examples
Stars: ✭ 24 (-27.27%)
Mutual labels:  example
awesome-iterative-projects
A list of projects relying on Iterative.AI tools to achieve awesomeness
Stars: ✭ 38 (+15.15%)
Mutual labels:  example
instagram-oauth-nodejs-server
Node.js server for Intagram-API OAuth purpose.
Stars: ✭ 12 (-63.64%)
Mutual labels:  example
python-code-disasters
This code is so bad, that it is worth sharing.
Stars: ✭ 134 (+306.06%)
Mutual labels:  example
sdl-imgui-example
An example of using Dear ImGui with SDL
Stars: ✭ 18 (-45.45%)
Mutual labels:  example

A simple Golang templates example

Go Report Card Build Status codecov

During the process of learning Golang templates, certain aspects were confusing to me. The goal of this little repo is to document what I eventually wound up doing. Hopefully with feedback this repo could serve as an example of at least one way to use templates effectively.

By no means is this intended to be a proper (or even correct) howto on Golang templates, rather it's just what I've learned so far. Here's what I was trying to accomplish:

  1. Have a directory of templates (header.html, foobar.html, etc).
  2. Have a directory of static files (css, images, etc).
  3. Use some templates as full pages (about.html, hello.html).
  4. Use some templates as partials (header.html, footer.html).
  5. Serve static content in a manner similar to http.FileServer.
  6. Exclude templates from the static files being served.
  7. Support custom template functions.
  8. Compile everything into a single static binary (including templates and static files).

Installation

go get github.com/GeertJohan/go.rice/rice
go get -d github.com/jmcfarlane/golang-templates-example

Run

cd $GOPATH/src/github.com/jmcfarlane/golang-templates-example
go get -t ./...
go generate
go test -v
go build
./golang-templates-example
curl http://localhost:8080

Optionally use make

If you have make installed, you can try this repo by doing:

make
./golang-templates-example
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].