mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Add Ace template engine support
This commit is contained in:
parent
390c158f4e
commit
a0d956c2ad
1 changed files with 19 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue