forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.go
45 lines (40 loc) · 1.08 KB
/
render.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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["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
}
e := &Engine{
Options: opts,
}
return e
}