forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.go
41 lines (36 loc) · 1.03 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
package render
import (
"sync"
"github.com/gobuffalo/buffalo/render/resolvers"
"github.com/gobuffalo/velvet"
)
// Engine used to power all defined renderers.
// This allows you to configure the system to your
// prefered settings, instead of just getting
// the defaults.
type Engine struct {
Options
templateCache map[string]*velvet.Template
moot *sync.Mutex
}
// New render.Engine ready to go with your Options
// and some defaults we think you might like. Engines
// have the following helpers added to them:
// https://github.com/gobuffalo/buffalo/blob/master/render/helpers/helpers.go#L1
// https://github.com/markbates/inflect/blob/master/helpers.go#L3
func New(opts Options) *Engine {
if opts.Helpers == nil {
opts.Helpers = map[string]interface{}{}
}
if opts.FileResolverFunc == nil {
opts.FileResolverFunc = func() resolvers.FileResolver {
return &resolvers.SimpleResolver{}
}
}
e := &Engine{
Options: opts,
templateCache: map[string]*velvet.Template{},
moot: &sync.Mutex{},
}
return e
}