From ffcb4aeb8e392a80da7cad0f1e03a4102efb24ec Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen 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 --- hugolib/template_test.go | 81 ------------------------------------------------ 1 file changed, 81 deletions(-) (limited to 'hugolib/template_test.go') diff --git a/hugolib/template_test.go b/hugolib/template_test.go index 99e57c75f..9f04aabdd 100644 --- a/hugolib/template_test.go +++ b/hugolib/template_test.go @@ -245,87 +245,6 @@ Page Content } -func TestTemplateLateTemplates(t *testing.T) { - t.Parallel() - b := newTestSitesBuilder(t).WithSimpleConfigFile().Running() - - numPages := 500 // To get some parallelism - homeTempl := ` -Len RegularPages: {{ len site.RegularPages }} -{{ range site.RegularPages }} -Link: {{ .RelPermalink }} Len Content: {{ len .Content }} -{{ end }} -` - pageTemplate := ` - - - - {{ .RelPermalink }} - - - - - -

{{ .RelPermalink }}

-

Shortcode: {{< shortcode >}}

-

Partial: {{ partial "mypartial.html" . }}

- - - -` - - b.WithTemplatesAdded( - "index.html", homeTempl, - "partials/mypartial.html", `this my partial`, - ) - - // Make sure we get some parallelism. - for i := 0; i < numPages; i++ { - b.WithContent(fmt.Sprintf("page%d.html", i+1), pageTemplate) - } - - b.Build(BuildCfg{}) - - b.AssertFileContent("public/index.html", fmt.Sprintf(` -Len RegularPages: %d -Link: /page3/ Len Content: 0 -Link: /page22/ Len Content: 0 -`, numPages)) - - for i := 0; i < numPages; i++ { - b.AssertFileContent(fmt.Sprintf("public/page%d/index.html", i+1), - fmt.Sprintf(`/page%d/`, i+1), - `

Shortcode: Shortcode: Hello

`, - "

Partial: this my partial

", - ) - } - - b.EditFiles( - "layouts/partials/mypartial.html", `this my changed partial`, - "layouts/index.html", (homeTempl + "CHANGED"), - ) - for i := 0; i < 5; i++ { - b.EditFiles(fmt.Sprintf("content/page%d.html", i+1), pageTemplate+"CHANGED") - } - - b.Build(BuildCfg{}) - b.AssertFileContent("public/index.html", fmt.Sprintf(` -Len RegularPages: %d -Link: /page3/ Len Content: 0 -Link: /page2/ Len Content: 0 -CHANGED -`, numPages)) - for i := 0; i < 5; i++ { - b.AssertFileContent(fmt.Sprintf("public/page%d/index.html", i+1), - fmt.Sprintf(`/page%d/`, i+1), - `

Shortcode: Shortcode: Hello

`, - "

Partial: this my changed partial

", - "CHANGED", - ) - } - -} - func TestTemplateManyBaseTemplates(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t).WithSimpleConfigFile() -- cgit v1.2.3