diff options
Diffstat (limited to 'modules/templates/static.go')
-rw-r--r-- | modules/templates/static.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/templates/static.go b/modules/templates/static.go index 65b82053fd..c16b18cc08 100644 --- a/modules/templates/static.go +++ b/modules/templates/static.go @@ -43,8 +43,7 @@ func (templates templateFileSystem) Get(name string) (io.Reader, error) { return nil, fmt.Errorf("file '%s' not found", name) } -// Renderer implements the macaron handler for serving the templates. -func Renderer() macaron.Handler { +func NewTemplateFileSystem() templateFileSystem { fs := templateFileSystem{} fs.files = make([]macaron.TemplateFile, 0, 10) @@ -110,9 +109,25 @@ func Renderer() macaron.Handler { } } + return fs +} + +var tplFileSys = NewTemplateFileSystem() + +// HTMLRenderer implements the macaron handler for serving HTML templates. +func HTMLRenderer() macaron.Handler { + return macaron.Renderer(macaron.RenderOptions{ + Funcs: NewFuncMap(), + TemplateFileSystem: tplFileSys, + }) +} + +// JSONRenderer implements the macaron handler for serving JSON templates. +func JSONRenderer() macaron.Handler { return macaron.Renderer(macaron.RenderOptions{ Funcs: NewFuncMap(), - TemplateFileSystem: fs, + TemplateFileSystem: tplFileSys, + HTMLContentType: "application/json", }) } |