output: Rework the base template logic

Extract the logic to a testable function and add support for custom output types.

Fixes #2995
This commit is contained in:
Bjørn Erik Pedersen
2017-03-19 21:09:31 +01:00
parent c7c6b47ba8
commit baa29f6534
8 changed files with 394 additions and 91 deletions

View File

@@ -923,10 +923,11 @@ func (p *Page) update(f interface{}) error {
p.s.Log.ERROR.Printf("Failed to parse lastmod '%v' in page %s", v, p.File.Path())
}
case "outputs":
outputs := cast.ToStringSlice(v)
if len(outputs) > 0 {
o := cast.ToStringSlice(v)
if len(o) > 0 {
// Output formats are exlicitly set in front matter, use those.
outFormats, err := output.GetTypes(outputs...)
outFormats, err := output.GetFormats(o...)
if err != nil {
p.s.Log.ERROR.Printf("Failed to resolve output formats: %s", err)
} else {