Skip to content

Instantly share code, notes, and snippets.

@xNok
Last active April 6, 2021 03:35
Show Gist options
  • Save xNok/337bcb2a6dbf4fd284d92a38e63fabe3 to your computer and use it in GitHub Desktop.
Save xNok/337bcb2a6dbf4fd284d92a38e63fabe3 to your computer and use it in GitHub Desktop.
func renderTemplate(fs fs.FS, file string
, args interface{}) bytes.Buffer {
var tpl bytes.Buffer
// read the block-kit definition as a go template
t, err := template.ParseFS(fs, file)
if err != nil {
panic(err)
}
// render the template using provided datas
err = t.Execute(&tpl, args)
if err != nil {
panic(err)
}
return tpl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment