1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-11-29 22:48:19 +02:00

Add basic string functions to templates (#514)

* Add basic string functions to templates

Co-authored-by: Oliver <oliver006@users.noreply.github.com>
Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
Co-authored-by: Henry Jenkins <henry@henryjenkins.name>
This commit is contained in:
n-i-x
2020-05-09 16:05:51 -04:00
committed by GitHub
parent 9d626265e8
commit be9eaaeb48
3 changed files with 57 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"html/template"
"path"
"strings"
"github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
)
@@ -12,7 +13,11 @@ func loadTemplates(dir string) *template.Template {
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"))
funcMap := template.FuncMap{
"ToUpper": strings.ToUpper,
"ToLower": strings.ToLower,
}
t, err := template.New("").Funcs(funcMap).ParseFiles(path.Join(dir, "sign_in.html"), path.Join(dir, "error.html"))
if err != nil {
logger.Fatalf("failed parsing template %s", err)
}