diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-04-02 14:20:34 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-04-02 14:20:34 +0200 |
commit | 7eb71ee06419f9ceedfd701ab2a27513ef448829 (patch) | |
tree | 254ba6c75575e067df76b4abe4e566936619adcb /hugolib/alias.go | |
parent | c97dae40d9cd24c467f5b8cfbe2ac06f3cdef1d2 (diff) | |
download | hugo-7eb71ee06419f9ceedfd701ab2a27513ef448829.tar.gz hugo-7eb71ee06419f9ceedfd701ab2a27513ef448829.zip |
Revert "tpl: Rework to handle both text and HTML templates"
Will have to take another stab at this ...
This reverts commit 5c5efa03d2512749950b0d05a7d4bde35ecbdc37.
Closes #3260
Diffstat (limited to 'hugolib/alias.go')
-rw-r--r-- | hugolib/alias.go | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/hugolib/alias.go b/hugolib/alias.go index 454744d9b..d5eb35777 100644 --- a/hugolib/alias.go +++ b/hugolib/alias.go @@ -22,8 +22,6 @@ import ( "runtime" "strings" - "github.com/spf13/hugo/tpl" - jww "github.com/spf13/jwalterweatherman" "github.com/spf13/hugo/helpers" @@ -37,19 +35,18 @@ const ( var defaultAliasTemplates *template.Template func init() { - //TODO(bep) consolidate defaultAliasTemplates = template.New("") template.Must(defaultAliasTemplates.New("alias").Parse(alias)) template.Must(defaultAliasTemplates.New("alias-xhtml").Parse(aliasXHtml)) } type aliasHandler struct { - t tpl.TemplateHandler + Templates *template.Template log *jww.Notepad allowRoot bool } -func newAliasHandler(t tpl.TemplateHandler, l *jww.Notepad, allowRoot bool) aliasHandler { +func newAliasHandler(t *template.Template, l *jww.Notepad, allowRoot bool) aliasHandler { return aliasHandler{t, l, allowRoot} } @@ -59,19 +56,12 @@ func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (i t = "alias-xhtml" } - var templ *tpl.TemplateAdapter - - if a.t != nil { - templ = a.t.Lookup("alias.html") + template := defaultAliasTemplates + if a.Templates != nil { + template = a.Templates + t = "alias.html" } - if templ == nil { - def := defaultAliasTemplates.Lookup(t) - if def != nil { - templ = &tpl.TemplateAdapter{def} - } - - } data := struct { Permalink string Page *Page @@ -81,7 +71,7 @@ func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (i } buffer := new(bytes.Buffer) - err := templ.Execute(buffer, data) + err := template.ExecuteTemplate(buffer, t, data) if err != nil { return nil, err } @@ -93,7 +83,8 @@ func (s *Site) writeDestAlias(path, permalink string, p *Page) (err error) { } func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, p *Page) (err error) { - handler := newAliasHandler(s.Tmpl, s.Log, allowRoot) + + handler := newAliasHandler(s.Tmpl.Lookup("alias.html"), s.Log, allowRoot) isXHTML := strings.HasSuffix(path, ".xhtml") |