package responses
import (
"fmt"
"html/template"
"net/http"
"git.kirsle.net/apps/gophertype/pkg/constants"
)
// TemplateFuncs available to all templates.
func TemplateFuncs(r *http.Request) template.FuncMap {
return template.FuncMap{
"CSRF": func() template.HTML {
fmt.Println("CSRF() func called")
token, _ := r.Cookie(constants.CSRFCookieName)
return template.HTML(fmt.Sprintf(
``,
constants.CSRFFormName,
token.Value,
))
},
"TestFunction": func() template.HTML {
return template.HTML("Testing")
},
}
}