aceberg/miniboard

View on GitHub
internal/web/exec-tpl.go

Summary

Maintainability
A
0 mins
Test Coverage
package web

import (
    "html/template"
    "net/http"

    "github.com/aceberg/miniboard/internal/check"
    "github.com/aceberg/miniboard/internal/models"
)

func execTemplate(w http.ResponseWriter, tpl string, guiData models.GuiData) {
    // tmpl, err := template.ParseFiles(TemplPath+tpl+".html", TemplPath+"header.html", TemplPath+"footer.html")
    tmpl, err := template.ParseFS(TemplHTML, TemplPath+tpl+".html", TemplPath+"header.html", TemplPath+"footer.html")
    check.IfError(err)
    err = tmpl.ExecuteTemplate(w, "header", guiData)
    check.IfError(err)
    err = tmpl.ExecuteTemplate(w, tpl, guiData)
    check.IfError(err)
}