Skip to content

Commit

Permalink
Add Ace template engine support
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsushid authored and spf13 committed Dec 3, 2014
1 parent 390c158 commit a0d956c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tpl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a0d956c

Please sign in to comment.