footer und AppVersion eingebaut
All checks were successful
Docker Release Build / push_to_registry (push) Successful in 1m2s
All checks were successful
Docker Release Build / push_to_registry (push) Successful in 1m2s
This commit is contained in:
25
main.go
25
main.go
@@ -12,13 +12,30 @@ const (
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
)
|
||||
|
||||
//var tmpl *template.Template
|
||||
var templates = make(map[string]*template.Template)
|
||||
var AppVersion = "development"
|
||||
|
||||
func loadTemplates() {
|
||||
templates["index.html"] = template.Must(template.ParseFiles("templates/base.html", "templates/index.html"))
|
||||
templates["help.html"] = template.Must(template.ParseFiles("templates/base.html", "templates/help.html"))
|
||||
log.Printf("Alle Templates erfolgreich geladen")
|
||||
// 1. FuncMap definieren
|
||||
funcMap := template.FuncMap{
|
||||
"getAppVersion": func() string {
|
||||
return AppVersion
|
||||
},
|
||||
}
|
||||
|
||||
// 2. Templates mit FuncMap laden
|
||||
// Wir nutzen New("base.html"), da base.html meist das Haupt-Layout definiert
|
||||
templates["index.html"] = template.Must(template.New("base.html").Funcs(funcMap).ParseFiles(
|
||||
"templates/base.html",
|
||||
"templates/index.html",
|
||||
))
|
||||
|
||||
templates["help.html"] = template.Must(template.New("base.html").Funcs(funcMap).ParseFiles(
|
||||
"templates/base.html",
|
||||
"templates/help.html",
|
||||
))
|
||||
|
||||
log.Printf("Alle Templates erfolgreich geladen")
|
||||
}
|
||||
|
||||
func generatePassword() string {
|
||||
|
||||
Reference in New Issue
Block a user