mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
30 lines
498 B
Go
30 lines
498 B
Go
package templates
|
|
|
|
import (
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
var templates *template.Template
|
|
|
|
type Page struct {
|
|
Title string
|
|
Login *LoginPage
|
|
}
|
|
|
|
type LoginPage struct {
|
|
Error string
|
|
Info string
|
|
}
|
|
|
|
func init() {
|
|
templates = template.Must(template.ParseGlob("./templates/*.html"))
|
|
}
|
|
|
|
func Render(rw http.ResponseWriter, r *http.Request, name string, page *Page) {
|
|
if err := templates.ExecuteTemplate(rw, name, page); err != nil {
|
|
log.Printf("template error: %s\n", err.Error())
|
|
}
|
|
}
|