package main import ( "html/template" "path" "github.com/pusher/oauth2_proxy/logger" ) func loadTemplates(dir string) *template.Template { if dir == "" { return getTemplates() } logger.Printf("using custom template directory %q", dir) t, err := template.New("").ParseFiles(path.Join(dir, "sign_in.html"), path.Join(dir, "error.html")) if err != nil { logger.Fatalf("failed parsing template %s", err) } return t } func getTemplates() *template.Template { t, err := template.New("foo").Parse(`{{define "sign_in.html"}} Sign In
{{ if .SignInMessage }}

{{.SignInMessage}}

{{ end}}
{{ if .CustomLogin }}


{{ end }} {{end}}`) if err != nil { logger.Fatalf("failed parsing template %s", err) } t, err = t.Parse(`{{define "error.html"}} {{.Title}}

{{.Title}}

{{.Message}}


Sign In

{{end}}`) if err != nil { logger.Fatalf("failed parsing template %s", err) } return t }