github.com/bscott/buffalo@v0.11.1/render/render.go (about) 1 package render 2 3 import ( 4 "github.com/gobuffalo/plush" 5 ) 6 7 // Engine used to power all defined renderers. 8 // This allows you to configure the system to your 9 // preferred settings, instead of just getting 10 // the defaults. 11 type Engine struct { 12 Options 13 } 14 15 // New render.Engine ready to go with your Options 16 // and some defaults we think you might like. 17 func New(opts Options) *Engine { 18 if opts.Helpers == nil { 19 opts.Helpers = map[string]interface{}{} 20 } 21 22 if opts.TemplateEngines == nil { 23 opts.TemplateEngines = map[string]TemplateEngine{} 24 } 25 if _, ok := opts.TemplateEngines["html"]; !ok { 26 opts.TemplateEngines["html"] = plush.BuffaloRenderer 27 } 28 if _, ok := opts.TemplateEngines["text"]; !ok { 29 opts.TemplateEngines["text"] = plush.BuffaloRenderer 30 } 31 if _, ok := opts.TemplateEngines["js"]; !ok { 32 opts.TemplateEngines["js"] = JSTemplateEngine 33 } 34 if _, ok := opts.TemplateEngines["md"]; !ok { 35 opts.TemplateEngines["md"] = MDTemplateEngine 36 } 37 if _, ok := opts.TemplateEngines["tmpl"]; !ok { 38 opts.TemplateEngines["tmpl"] = GoTemplateEngine 39 } 40 41 e := &Engine{ 42 Options: opts, 43 } 44 return e 45 }