Sharing data with templates: cycle import error

This commit is contained in:
Muyao CHEN
2024-06-28 10:40:47 +02:00
parent 1dd22ba8db
commit 668e88e578
3 changed files with 22 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package render
import (
"bytes"
"go-udemy-web-1/pkg/config"
"go-udemy-web-1/pkg/handlers"
"html/template"
"log"
"net/http"
@ -17,7 +18,7 @@ func NewTemplates(a *config.AppConfig) {
}
// RenderTemplate renders a HTML template file
func RenderTemplate(w http.ResponseWriter, tmpl string) {
func RenderTemplate(w http.ResponseWriter, tmpl string, td *handlers.TemplateData) {
var tc map[string]*template.Template
if app.UseCache {
// get the template cache from the app config