summaryrefslogtreecommitdiffstats
path: root/tpl/tplimpl/template.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-10 08:02:15 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-12 09:59:34 +0100
commit167c01530bb295c8b8d35921eb27ffa5bee76dfe (patch)
tree338ba8c18bf8533bb0fec5506a12e78b656d6723 /tpl/tplimpl/template.go
parent4c804319f6db0b8459cc9b5df4a904fd2c55dedd (diff)
Create lightweight forks of text/template and html/template
This commit also removes support for Ace and Amber templates. Updates #6594
Diffstat (limited to 'tpl/tplimpl/template.go')
-rw-r--r--tpl/tplimpl/template.go82
1 files changed, 9 insertions, 73 deletions
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go
index 602777524..0feb3a0de 100644
--- a/tpl/tplimpl/template.go
+++ b/tpl/tplimpl/template.go
@@ -15,17 +15,18 @@ package tplimpl
import (
"fmt"
- "html/template"
+
"strings"
- texttemplate "text/template"
- "text/template/parse"
+
+ template "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate"
+
+ texttemplate "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate"
+ "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/parse"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/tpl/tplimpl/embedded"
"github.com/pkg/errors"
- "github.com/eknkc/amber"
-
"os"
"github.com/gohugoio/hugo/output"
@@ -56,9 +57,6 @@ var (
_ templateFuncsterTemplater = (*textTemplates)(nil)
)
-// Protecting global map access (Amber)
-var amberMu sync.Mutex
-
type templateErr struct {
name string
err error
@@ -98,8 +96,6 @@ type templateHandler struct {
text *textTemplates
html *htmlTemplates
- amberFuncMap template.FuncMap
-
errors []*templateErr
// This is the filesystem to load the templates from. All the templates are
@@ -778,23 +774,6 @@ func (t *templateHandler) initFuncs() {
}
}
- // Amber is HTML only.
- t.amberFuncMap = template.FuncMap{}
-
- amberMu.Lock()
- for k, v := range amber.FuncMap {
- t.amberFuncMap[k] = v
- }
-
- for k, v := range t.html.funcster.funcMap {
- t.amberFuncMap[k] = v
- // Hacky, but we need to make sure that the func names are in the global map.
- amber.FuncMap[k] = func() string {
- panic("should never be invoked")
- }
- }
- amberMu.Unlock()
-
}
func (t *templateHandler) getTemplateHandler(name string) templateLoader {
@@ -933,54 +912,11 @@ func (t *templateHandler) addTemplateFile(name, baseTemplatePath, path string) e
ext := filepath.Ext(path)
switch ext {
case ".amber":
- // Only HTML support for Amber
- withoutExt := strings.TrimSuffix(name, filepath.Ext(name))
- templateName := withoutExt + ".html"
- b, err := afero.ReadFile(t.Layouts.Fs, path)
-
- if err != nil {
- return err
- }
-
- amberMu.Lock()
- templ, err := t.compileAmberWithTemplate(b, path, t.html.t.New(templateName))
- amberMu.Unlock()
- if err != nil {
- return err
- }
-
- typ := resolveTemplateType(name)
-
- c, err := applyTemplateTransformersToHMLTTemplate(typ, templ)
- if err != nil {
- return err
- }
-
- if typ == templateShortcode {
- t.addShortcodeVariant(templateName, c.Info, templ)
- } else {
- t.templateInfo[name] = c.Info
- }
-
+ helpers.Deprecated("Amber templates are no longer supported.", "Use Go templates or a Hugo version <= 0.60.", true)
return nil
-
case ".ace":
- // Only HTML support for Ace
- var innerContent, baseContent []byte
- innerContent, err := afero.ReadFile(t.Layouts.Fs, path)
-
- if err != nil {
- return err
- }
-
- if baseTemplatePath != "" {
- baseContent, err = afero.ReadFile(t.Layouts.Fs, baseTemplatePath)
- if err != nil {
- return err
- }
- }
-
- return t.addAceTemplate(name, baseTemplatePath, path, baseContent, innerContent)
+ helpers.Deprecated("ACE templates are no longer supported.", "Use Go templates or a Hugo version <= 0.60.", true)
+ return nil
default:
if baseTemplatePath != "" {