func renderTemplate(filepath string, data map[string]interface{}) []byte { var out string var err error var template pongo2.Template // Read the template from the disk every time if ServerConfig.Debug { newTemplate, err := pongo2.FromFile(filepath) if err != nil { panic(err) } template = *newTemplate } else { // Read the template and cache it cached, ok := templateCache[filepath] if ok == false { newTemplate, err := pongo2.FromFile(filepath) if err != nil { panic(err) } templateCache[filepath] = *newTemplate cached = *newTemplate } template = cached } out, err = template.Execute(data) if err != nil { panic(err) } return []byte(out) }