forked from mystiq/dex
28 lines
447 B
Go
28 lines
447 B
Go
package internal
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
)
|
|
|
|
func RenderTemplates(argTemplates []string, data interface{}) (args []string, err error) {
|
|
var t *template.Template
|
|
|
|
for _, arg := range argTemplates {
|
|
t, err = template.New(arg).Parse(arg)
|
|
if err != nil {
|
|
args = nil
|
|
return
|
|
}
|
|
|
|
buf := &bytes.Buffer{}
|
|
err = t.Execute(buf, data)
|
|
if err != nil {
|
|
args = nil
|
|
return
|
|
}
|
|
args = append(args, buf.String())
|
|
}
|
|
|
|
return
|
|
}
|