diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 3f1a8b066..483d6ae71 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -436,6 +436,8 @@ func TestSkipRender(t *testing.T) { {Name: filepath.FromSlash("sect/doc6.html"), Content: []byte("{{ template \"head_abs\" }}body5")}, {Name: filepath.FromSlash("doc7.html"), Content: []byte("doc7 content")}, {Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")}, + // Issue #3021 + {Name: filepath.FromSlash("doc9.html"), Content: []byte("doc9: {{< myshortcode >}}")}, } viper.Set("defaultExtension", "html") @@ -454,6 +456,7 @@ func TestSkipRender(t *testing.T) { writeSource(t, fs, filepath.Join("layouts", "_default/single.html"), "{{.Content}}") writeSource(t, fs, filepath.Join("layouts", "head"), "") writeSource(t, fs, filepath.Join("layouts", "head_abs"), "") + writeSource(t, fs, filepath.Join("layouts", "shortcodes", "myshortcode.html"), "SHORT") buildSingleSite(t, deps.DepsCfg{Fs: fs}, BuildCfg{}) @@ -469,6 +472,7 @@ func TestSkipRender(t *testing.T) { {filepath.FromSlash("public/sect/doc6.html"), "body5"}, {filepath.FromSlash("public/doc7.html"), "doc7 content"}, {filepath.FromSlash("public/sect/doc8.html"), "\n\n

title

\n\n

some content

\n"}, + {filepath.FromSlash("public/doc9.html"), "doc9: SHORT"}, } for _, test := range tests { diff --git a/tpl/template.go b/tpl/template.go index 9efb8869a..844608014 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -141,7 +141,6 @@ func (t *GoHTMLTemplate) initFuncs(d *deps.Deps) { // 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") - return "" } } @@ -197,12 +196,18 @@ func (t *GoHTMLTemplate) ExecuteTemplateToHTML(context interface{}, layouts ...s func (t *GoHTMLTemplate) Lookup(name string) *template.Template { + if templ := t.Template.Lookup(name); templ != nil { + return templ + } + if t.overlays != nil { if templ, ok := t.overlays[name]; ok { return templ } } + // The clone is used for the non-renderable HTML pages (p.IsRenderable == false) that is parsed + // as Go templates late in the build process. if t.clone != nil { if templ := t.clone.Lookup(name); templ != nil { return templ