Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Created July 26, 2015 20:33
Show Gist options
  • Save alyssaq/5af1f73a65d0b4a4ccb0 to your computer and use it in GitHub Desktop.
Save alyssaq/5af1f73a65d0b4a4ccb0 to your computer and use it in GitHub Desktop.
func renderTemplate(w http.ResponseWriter, tmpl string, str string) {
var fp = path.Join("templates", "index.html")
var templates = template.Must(template.ParseFiles(fp))
err := templates.ExecuteTemplate(w, tmpl+".html", str)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment