github.com/rotblauer/buffalo@v0.7.1-0.20170112214545-7aa55ef80dd3/render/render.go (about) 1 package render 2 3 import ( 4 "sync" 5 6 "github.com/gobuffalo/buffalo/render/resolvers" 7 "github.com/gobuffalo/velvet" 8 ) 9 10 // Engine used to power all defined renderers. 11 // This allows you to configure the system to your 12 // prefered settings, instead of just getting 13 // the defaults. 14 type Engine struct { 15 Options 16 templateCache map[string]*velvet.Template 17 moot *sync.Mutex 18 } 19 20 // New render.Engine ready to go with your Options 21 // and some defaults we think you might like. Engines 22 // have the following helpers added to them: 23 // https://github.com/gobuffalo/buffalo/blob/master/render/helpers/helpers.go#L1 24 // https://github.com/markbates/inflect/blob/master/helpers.go#L3 25 func New(opts Options) *Engine { 26 if opts.Helpers == nil { 27 opts.Helpers = map[string]interface{}{} 28 } 29 if opts.FileResolverFunc == nil { 30 opts.FileResolverFunc = func() resolvers.FileResolver { 31 return &resolvers.SimpleResolver{} 32 } 33 } 34 35 e := &Engine{ 36 Options: opts, 37 templateCache: map[string]*velvet.Template{}, 38 moot: &sync.Mutex{}, 39 } 40 return e 41 }