github.com/rotblauer/buffalo@v0.7.1-0.20170112214545-7aa55ef80dd3/render/options.go (about)

     1  package render
     2  
     3  import "github.com/gobuffalo/buffalo/render/resolvers"
     4  
     5  // Options for render.Engine
     6  type Options struct {
     7  	// HTMLLayout is the default layout to be used with all HTML renders.
     8  	HTMLLayout string
     9  	// TemplatesPath is the location of the templates directory on disk.
    10  	TemplatesPath string
    11  	// FileResolverFunc will attempt to file a file and return it's bytes, if possible
    12  	FileResolverFunc func() resolvers.FileResolver
    13  	fileResolver     resolvers.FileResolver
    14  	// Helpers to be rendered with the templates
    15  	Helpers map[string]interface{}
    16  	// CacheTemplates reduced overheads, but won't reload changed templates.
    17  	// This should only be set to true in production environments.
    18  	CacheTemplates bool
    19  }
    20  
    21  // Resolver calls the FileResolverFunc and returns the resolver. The resolver
    22  // is cached, so the function can be called multiple times without penalty.
    23  // This is necessary because certain resolvers, like the RiceBox one, require
    24  // a fully initialized state to work properly and can not be run directly from
    25  // init functions.
    26  func (o *Options) Resolver() resolvers.FileResolver {
    27  	if o.fileResolver == nil {
    28  		o.fileResolver = o.FileResolverFunc()
    29  	}
    30  	return o.fileResolver
    31  }