Files
athens/vendor/github.com/gobuffalo/buffalo/render/render.go
Henry Jenkins d26b99d41c Upgrade Buffalo (#789)
* Upgrade buffalo

* Switch to go modules everywhere

* Fixes from buffalo fix

* Add missing modules from module list

* Update vendored modules in /vendor

* Stop using vendor directory for tests

* Check go.mod and go.sum files on verify

* Upgrade Buffalo from v0.13.0 to v0.13.1

* Fix test for new Buffalo

Allow for new Buffalo code

* Add test for endpoint with trailing slash
2018-10-23 16:49:32 -07:00

53 lines
1.3 KiB
Go

package render
import (
"github.com/gobuffalo/plush"
)
// Engine used to power all defined renderers.
// This allows you to configure the system to your
// preferred settings, instead of just getting
// the defaults.
type Engine struct {
Options
}
// New render.Engine ready to go with your Options
// and some defaults we think you might like.
func New(opts Options) *Engine {
if opts.Helpers == nil {
opts.Helpers = map[string]interface{}{}
}
if opts.TemplateEngines == nil {
opts.TemplateEngines = map[string]TemplateEngine{}
}
if _, ok := opts.TemplateEngines["html"]; !ok {
opts.TemplateEngines["html"] = plush.BuffaloRenderer
}
if _, ok := opts.TemplateEngines["text"]; !ok {
opts.TemplateEngines["text"] = plush.BuffaloRenderer
}
if _, ok := opts.TemplateEngines["txt"]; !ok {
opts.TemplateEngines["txt"] = plush.BuffaloRenderer
}
if _, ok := opts.TemplateEngines["js"]; !ok {
opts.TemplateEngines["js"] = JSTemplateEngine
}
if _, ok := opts.TemplateEngines["md"]; !ok {
opts.TemplateEngines["md"] = MDTemplateEngine
}
if _, ok := opts.TemplateEngines["tmpl"]; !ok {
opts.TemplateEngines["tmpl"] = GoTemplateEngine
}
if opts.DefaultContentType == "" {
opts.DefaultContentType = "text/html; charset=utf-8"
}
e := &Engine{
Options: opts,
}
return e
}