commit 8d450acadd93f08c72b3f28b26ac35b8f0b17f8a
parent ebc2a6c041fd0c47e3bd759a9d69569e490e5254
Author: gearsix <gearsix@tuta.io>
Date: Thu, 7 Oct 2021 13:28:11 +0100
fixed .Name assignment
Diffstat:
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/template.go b/template.go
@@ -106,10 +106,7 @@ func LoadTemplateFilepath(rootPath string, partialPaths ...string) (t Template,
lang := strings.TrimPrefix(filepath.Ext(rootPath), ".")
- rootName := filepath.Base(rootPath)
- if lang == "mst" {
- rootName = strings.TrimSuffix(rootName, filepath.Ext(rootName))
- }
+ rootName := strings.TrimSuffix(filepath.Base(rootPath), filepath.Ext(rootPath))
var root *os.File
if root, e = os.Open(rootPath); e != nil {
@@ -124,12 +121,11 @@ func LoadTemplateFilepath(rootPath string, partialPaths ...string) (t Template,
name = strings.TrimSuffix(name, filepath.Ext(name))
}
- var p *os.File
if stat, e = os.Stat(path); e != nil {
return
- } else if stat.IsDir() {
}
+ var p *os.File
if p, e = os.Open(path); e != nil {
return
}
@@ -226,6 +222,7 @@ func LoadTemplate(lang string, rootName string, root io.Reader, partials map[str
return
}
+ t.Name = rootName
switch lang {
case "tmpl":
t.T, e = loadTemplateTmpl(rootName, root, partials)