1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 12:30:54 +00:00

Fix index out of range if there is no file extension

This commit is contained in:
saturn4er 2016-03-29 17:15:43 +03:00
parent 66423f6935
commit adaa4ab929

View File

@ -167,9 +167,11 @@ func BuildTemplate(dir string, files ...string) error {
for _, file := range v { for _, file := range v {
if buildAllFiles || utils.InSlice(file, files) { if buildAllFiles || utils.InSlice(file, files) {
templatesLock.Lock() templatesLock.Lock()
fileExt := filepath.Ext(file)[1:] ext := filepath.Ext(file)
var t TemplateRenderer var t TemplateRenderer
if fn, ok := beeTemplateEngines[fileExt]; ok { if len(ext) == 0 {
t, err = getTemplate(self.root, file, v...)
} else if fn, ok := beeTemplateEngines[ext[1:]]; ok {
t, err = fn(self.root, file, beegoTplFuncMap) t, err = fn(self.root, file, beegoTplFuncMap)
} else { } else {
t, err = getTemplate(self.root, file, v...) t, err = getTemplate(self.root, file, v...)