Standard library / html/template
html/template.FuncMap
Maps names to callable functions. Register functions before parsing actions that use them. Expected stdout: 'ADA\n'.
Formal Syntax & Structure
go syntaxgo
type FuncMap = template.FuncMapWorking Example
Example Snippetgo
package main
import ( "fmt" "html/template" "os" "strings")
func check(e error) { if e != nil { panic(e) }}
func main() { f := template.FuncMap{"upper": strings.ToUpper} t := template.Must(template.New("greet").Funcs(f).Parse("{{upper .}}")) check(t.Execute(os.Stdout, "Ada")) fmt.Println()}