Adding an html file handler

This commit is contained in:
spf13 2014-11-04 00:43:09 -05:00
parent 7fba250023
commit ade2ca6072

View file

@ -16,10 +16,11 @@ package hugolib
import "github.com/spf13/hugo/source"
func init() {
RegisterHandler(markdown)
RegisterHandler(markdownHandler)
RegisterHandler(htmlHandler)
}
var markdown = Handle{
var markdownHandler = Handle{
extensions: []string{"mdown", "markdown", "md"},
read: func(f *source.File, s *Site, results HandleResults) {
page, err := NewPage(f.Path())
@ -46,3 +47,31 @@ var markdown = Handle{
results <- HandledResult{err: err}
},
}
var htmlHandler = Handle{
extensions: []string{"html", "htm"},
read: func(f *source.File, s *Site, results HandleResults) {
page, err := NewPage(f.Path())
if err != nil {
results <- HandledResult{file: f, err: err}
}
if err := page.ReadFrom(f.Contents); err != nil {
results <- HandledResult{file: f, err: err}
}
page.Site = &s.Info
page.Tmpl = s.Tmpl
results <- HandledResult{file: f, page: page, err: err}
},
pageConvert: func(p *Page, s *Site, results HandleResults) {
p.ProcessShortcodes(s.Tmpl)
err := p.Convert()
if err != nil {
results <- HandledResult{err: err}
}
results <- HandledResult{err: err}
},
}