Add html template service provider factory

This commit is contained in:
wpetit 2018-12-07 09:57:07 +01:00
parent bd676c234f
commit 9b13461e93
1 changed files with 16 additions and 0 deletions

16
template/html/provider.go Normal file
View File

@ -0,0 +1,16 @@
package html
import "forge.cadoles.com/wpetit/goweb/service"
// ServiceProvider returns a service.Provider for the
// the HTML template service implementation
func ServiceProvider(templateDir string, funcs ...OptionFunc) service.Provider {
templateService := NewTemplateService(funcs...)
err := templateService.LoadTemplates(templateDir)
return func(container *service.Container) (interface{}, error) {
if err != nil {
return nil, err
}
return templateService, nil
}
}