tpl/tplimpl: Extract internal templates

Having them in separate files should make maintainance easier.

When adding new or making changes to the templates:

```bash
mage generate
```

This will get the Go code in sync.

Fixes #4457
This commit is contained in:
Bjørn Erik Pedersen
2018-05-04 17:53:56 +02:00
parent 914cc85e22
commit 34ad9a4f17
28 changed files with 520 additions and 163 deletions

View File

@@ -20,6 +20,8 @@ import (
"strings"
texttemplate "text/template"
"github.com/gohugoio/hugo/tpl/tplimpl/embedded"
"github.com/eknkc/amber"
"os"
@@ -682,23 +684,18 @@ func (t *templateHandler) addTemplateFile(name, baseTemplatePath, path string) e
return t.AddTemplate(name, templ)
}
}
func (t *templateHandler) loadEmbedded() {
t.embedShortcodes()
t.embedTemplates()
}
func (t *templateHandler) addInternalTemplate(prefix, name, tpl string) error {
if prefix != "" {
return t.AddTemplate("_internal/"+prefix+"/"+name, tpl)
for _, kv := range embedded.EmbeddedTemplates {
// TODO(bep) error handling
t.addInternalTemplate(kv[0], kv[1])
}
return t.AddTemplate("_internal/"+name, tpl)
}
func (t *templateHandler) addInternalShortcode(name, content string) error {
return t.addInternalTemplate("shortcodes", name, content)
func (t *templateHandler) addInternalTemplate(name, tpl string) error {
return t.AddTemplate("_internal/"+name, tpl)
}
func (t *templateHandler) checkState() {