From a0d956c2ad7371d989fc192e122f0097b07a5b01 Mon Sep 17 00:00:00 2001 From: Tatsushi Demachi Date: Tue, 30 Sep 2014 10:19:50 +0900 Subject: [PATCH] Add Ace template engine support --- tpl/template.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tpl/template.go b/tpl/template.go index 9ea84dea8..f61376552 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -30,6 +30,7 @@ import ( "github.com/spf13/cast" "github.com/spf13/hugo/helpers" jww "github.com/spf13/jwalterweatherman" + "github.com/yosssi/ace" ) var localTemplates *template.Template @@ -669,6 +670,24 @@ func (t *GoHtmlTemplate) AddTemplateFile(name, path string) error { if _, err := compiler.CompileWithTemplate(t.New(name)); err != nil { return err } + case ".ace": + b, err := ioutil.ReadFile(path) + if err != nil { + return err + } + name = name[:len(name)-len(ext)] + ".html" + base := ace.NewFile(path, b) + inner := ace.NewFile("", []byte{}) + rslt, err := ace.ParseSource(ace.NewSource(base, inner, []*ace.File{}), nil) + if err != nil { + t.errors = append(t.errors, &templateErr{name: name, err: err}) + return err + } + _, err = ace.CompileResultWithTemplate(t.New(name), rslt, nil) + if err != nil { + t.errors = append(t.errors, &templateErr{name: name, err: err}) + } + return err default: b, err := ioutil.ReadFile(path) if err != nil {