From ffcb4aeb8e392a80da7cad0f1e03a4102efb24ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 9 Mar 2020 12:04:33 +0100 Subject: Fix handling of HTML files without front matter This means that any HTML file inside /content will be treated as a regular file. If you want it processes with shortcodes and a layout, add front matter. The defintion of an HTML file here is: * File with extension .htm or .html * With first non-whitespace character "<" that isn't a HTML comment. This is in line with the documentation. Fixes #7030 Fixes #7028 See #6789 --- tpl/template.go | 1 - tpl/tplimpl/template.go | 32 ++------------------------------ 2 files changed, 2 insertions(+), 31 deletions(-) (limited to 'tpl') diff --git a/tpl/template.go b/tpl/template.go index b9b0749b6..315004b6a 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -29,7 +29,6 @@ type TemplateManager interface { TemplateHandler TemplateFuncGetter AddTemplate(name, tpl string) error - AddLateTemplate(name, tpl string) error MarkReady() error } diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go index b6313e1e5..c01b62136 100644 --- a/tpl/tplimpl/template.go +++ b/tpl/tplimpl/template.go @@ -251,21 +251,8 @@ func (t *templateExec) MarkReady() error { } }) - if err != nil { - return err - } - - if t.Deps.BuildFlags.HasLateTemplate.Load() { - // This costs memory, so try to avoid it if we don't have to. - // The late templates are used to handle HTML in files in /content - // without front matter. - t.readyLateInit.Do(func() { - t.late = t.main.Clone(true) - t.late.createPrototypes() - }) - } + return err - return nil } type templateHandler struct { @@ -273,10 +260,7 @@ type templateHandler struct { needsBaseof map[string]templateInfo baseof map[string]templateInfo - late *templateNamespace // Templates added after main has started executing. - - readyInit sync.Once - readyLateInit sync.Once + readyInit sync.Once // This is the filesystem to load the templates from. All the templates are // stored in the root of this filesystem. @@ -309,14 +293,6 @@ type templateHandler struct { templateInfo map[string]tpl.Info } -// AddLateTemplate is used to add a template after the -// regular templates have started its execution. -// These are currently "pure HTML content files". -func (t *templateHandler) AddLateTemplate(name, tpl string) error { - _, err := t.late.parse(t.newTemplateInfo(name, tpl)) - return err -} - // AddTemplate parses and adds a template to the collection. // Templates with name prefixed with "_text" will be handled as plain // text templates. @@ -334,10 +310,6 @@ func (t *templateHandler) Lookup(name string) (tpl.Template, bool) { return templ, true } - if t.late != nil { - return t.late.Lookup(name) - } - return nil, false } -- cgit v1.2.3