mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
24 lines
425 B
Go
24 lines
425 B
Go
package util
|
|
|
|
import (
|
|
"bytes"
|
|
"github.com/sirupsen/logrus"
|
|
"text/template"
|
|
)
|
|
|
|
func Render(tpl string, args interface{}) string {
|
|
var buf = bytes.NewBuffer(nil)
|
|
tmpl, err := template.New("tmp").Parse(tpl)
|
|
if err != nil {
|
|
logrus.WithError(err).Error("template error")
|
|
return ""
|
|
}
|
|
err = tmpl.Execute(buf, args)
|
|
if err != nil {
|
|
logrus.WithError(err).Error("template error")
|
|
return ""
|
|
}
|
|
return buf.String()
|
|
}
|
|
|