woodpecker-email/vendor/github.com/aymerick/raymond/raymond.go
Michael de Wit f128c947ab Refactor plugin to be compatible with Drone 0.5 (#13)
* Refactor plugin to be compatible with Drone 0.5

* Add vendor files

* Re-add logo.svg, make loading environment from .env file optional, and use drone-go/template

* Fix README

* Fix issue with date formatting, update the DOCS, and improve types

* Add working directory and volume mount to README example
2017-01-16 13:20:59 +01:00

29 lines
853 B
Go

// Package raymond provides handlebars evaluation
package raymond
// Render parses a template and evaluates it with given context
//
// Note that this function call is not optimal as your template is parsed everytime you call it. You should use Parse() function instead.
func Render(source string, ctx interface{}) (string, error) {
// parse template
tpl, err := Parse(source)
if err != nil {
return "", err
}
// renders template
str, err := tpl.Exec(ctx)
if err != nil {
return "", err
}
return str, nil
}
// MustRender parses a template and evaluates it with given context. It panics on error.
//
// Note that this function call is not optimal as your template is parsed everytime you call it. You should use Parse() function instead.
func MustRender(source string, ctx interface{}) string {
return MustParse(source).MustExec(ctx)
}