package main
import (
"os"
"text/template"
)
const emailTmpl = `Hi {{.Name}},
Thanks for signing up to {{.Product}}! You're on the {{.Plan}} plan.
{{if .Trial}}You have {{.TrialDays}} days of free trial.
{{end -}}
Visit https://{{.Product | lower}}.com/dashboard to get started.
`
func main() {
funcs := template.FuncMap{
"lower": strings.ToLower,
}
t := template.Must(template.New("email").Funcs(funcs).Parse(emailTmpl))
data := struct {
Name, Product, Plan string
Trial bool
TrialDays int
}{
Name: "Alice", Product: "MyApp", Plan: "Pro",
Trial: true, TrialDays: 14,
}
t.Execute(os.Stdout, data)
}
// import strings — omitted above for brevity
import "strings"
Create a free account and build your private vault. Share publicly whenever you want.