Add Ace template engine support
authorTatsushi Demachi <tdemachi@gmail.com>
Tue, 30 Sep 2014 01:19:50 +0000 (10:19 +0900)
committerspf13 <steve.francia@gmail.com>
Wed, 3 Dec 2014 14:38:36 +0000 (15:38 +0100)
tpl/template.go

index 9ea84dea8eb80c0d9841d2c82ac3afe7d0bfd190..f61376552c581ae774880bef8be0ca7c8ad66e88 100644 (file)
@@ -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 {