dati

data and template interface
git clone git://git.gearsix.net/dati
Log | Files | Refs | Atom | README | LICENSE

commit d61c1f8a3acd8e66fe7e8d2e81d86cc6367a9087
parent bf0bb315ccff85e05335085997a4ca485044a053
Author: gearsix <gearsix@tuta.io>
Date:   Sun, 11 Apr 2021 16:56:05 +0100

bugfixes, typo for mustache extensions

Diffstat:
Mtemplate.go | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/template.go b/template.go @@ -55,7 +55,7 @@ func loadTemplateFileTmpl(root string, partials ...string) (*tmpl.Template, erro t, e = t.ParseGlob(p) } else if stat.IsDir() { e = filepath.Walk(p, func(path string, info fs.FileInfo, err error) error { - if err == nil { + if err == nil && !info.IsDir() { ptype = getTemplateType(path) if ptype == "tmpl" || ptype == "gotmpl" { t, err = t.ParseFiles(path) @@ -88,7 +88,7 @@ func loadTemplateFileHmpl(root string, partials ...string) (*hmpl.Template, erro t, e = t.ParseGlob(p) } else if stat.IsDir() { e = filepath.Walk(p, func(path string, info fs.FileInfo, err error) error { - if err == nil { + if err == nil && !info.IsDir() { ptype = getTemplateType(path) if ptype == "hmpl" || ptype == "gohmpl" { t, err = t.ParseFiles(path) @@ -134,7 +134,7 @@ func loadTemplateFileMst(root string, partials ...string) (*mst.Template, error) mstfp := &mst.FileProvider{ Paths: partials, - Extensions: []string{".mst", ".mst"}, + Extensions: []string{".mst", ".mustache"}, } return mst.ParseFilePartials(root, mstfp) } @@ -179,11 +179,11 @@ func (t *Template) Execute(d interface{}) (result bytes.Buffer, err error) { var rval []reflect.Value if tt.String() == "*template.Template" { // tmpl or hmpl rval = tv.MethodByName("Execute").Call([]reflect.Value{ - reflect.ValueOf(&result), reflect.ValueOf(&d), + reflect.ValueOf(&result), reflect.ValueOf(d), }) } else if tt.String() == "*mustache.Template" { // mustache rval = tv.MethodByName("FRender").Call([]reflect.Value{ - reflect.ValueOf(&result), reflect.ValueOf(&d), + reflect.ValueOf(&result), reflect.ValueOf(d), }) } else { err = fmt.Errorf("unable to infer template type '%s'", tt.String())