Go on GAE: Auto-reload / refresh of HTML templates using the template pkg


If you wonder why the changes in your template.html aren't reflected on the server and whether it's not a bug — ...no, it's a feature... ;)
 
The solution to reparase your HTML template — at least while you're in dev mode — is to appropriately incorporate this code snippet into your app.
 
var myTemplate = template.MustParseFile("template.html", nil) 
func reparseHTMLtemplate(w http.ResponseWriter, r *http.Request) {
myTemplate, err = template.ParseFile("template.html", nil) 
fmt.Fprintln(w, "reloaded / refreshed / reparsed:", err) 
}
 
Thanks to Andrew Gerrand for this solution!

Comments

Popular posts from this blog

Apple's evaluating a new JVM

Tuning ext4 for performance with emphasis on SSD usage