Skip to content

Commit

Permalink
all: Use the configured output types to resolve template type
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Apr 4, 2017
1 parent d9afa2e commit 984ebb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/hugo/config"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/output"
"github.com/spf13/hugo/tpl"
jww "github.com/spf13/jwalterweatherman"
)
Expand Down Expand Up @@ -39,6 +40,9 @@ type Deps struct {

Language *helpers.Language

// All the output formats available for the current site.
OutputFormatsConfig output.Formats

templateProvider ResourceProvider
WithTemplate func(templ tpl.TemplateHandler) error `json:"-"`

Expand Down
2 changes: 2 additions & 0 deletions hugolib/hugo_sites.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func applyDepsIfNeeded(cfg deps.DepsCfg, sites ...*Site) error {
return err
}

d.OutputFormatsConfig = s.outputFormatsConfig
s.Deps = d

if err = d.LoadResources(); err != nil {
Expand All @@ -112,6 +113,7 @@ func applyDepsIfNeeded(cfg deps.DepsCfg, sites ...*Site) error {
if err != nil {
return err
}
d.OutputFormatsConfig = s.outputFormatsConfig
s.Deps = d
}

Expand Down
7 changes: 3 additions & 4 deletions tpl/tplimpl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ func (t *textTemplates) setFuncs(funcMap map[string]interface{}) {
// A prefix can be given to indicate a template namespace to load the templates
// into, i.e. "_internal" etc.
func (t *templateHandler) LoadTemplates(absPath, prefix string) {
// TODO(bep) output formats. Will have to get to complete list when that is ready.
t.loadTemplates(absPath, prefix, output.Formats{output.HTMLFormat, output.RSSFormat, output.CalendarFormat, output.AMPFormat, output.JSONFormat})
t.loadTemplates(absPath, prefix)

}

Expand Down Expand Up @@ -376,7 +375,7 @@ func (t *templateHandler) RebuildClone() {
t.text.clone = texttemplate.Must(t.text.cloneClone.Clone())
}

func (t *templateHandler) loadTemplates(absPath string, prefix string, formats output.Formats) {
func (t *templateHandler) loadTemplates(absPath string, prefix string) {
t.Log.DEBUG.Printf("Load templates from path %q prefix %q", absPath, prefix)
walker := func(path string, fi os.FileInfo, err error) error {
if err != nil {
Expand Down Expand Up @@ -428,7 +427,7 @@ func (t *templateHandler) loadTemplates(absPath string, prefix string, formats o
RelPath: relPath,
Prefix: prefix,
Theme: t.PathSpec.Theme(),
OutputFormats: formats,
OutputFormats: t.OutputFormatsConfig,
FileExists: func(filename string) (bool, error) {
return helpers.Exists(filename, t.Fs.Source)
},
Expand Down

0 comments on commit 984ebb2

Please sign in to comment.