github.com/aminjam/goflat@v0.4.1-0.20160331105230-ec639fc0d5b3/.examples/pipes/pipes.go (about) 1 package main 2 3 import ( 4 "strings" 5 "text/template" 6 ) 7 8 func CustomPipes() template.FuncMap { 9 return template.FuncMap{ 10 //This will override the default "replace" pipe. 11 "replace": func(old, new, s string) (string, error) { 12 //replace only the first occurrence of a value 13 return strings.Replace(s, old, new, 1), nil 14 }, 15 //This will extend the list of helper functions 16 "sanitize": func(a string) (string, error) { 17 if a == "SECRET" { 18 return "TERCES", nil 19 } 20 return a, nil 21 }, 22 } 23 }