mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-27 05:49:04 +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())
|
|
}
|
|
}
|