Category | golang |
Added on | 2020-07-30 |
Source | source |
tplSource := `
Test template with
`
t := template.New("example").Parse(tplSource)
data := struct{
Key string
}{
Key: "variable key"
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, data); err != nil {
return err
}
result := tpl.String() // or tpl.Bytes()