summaryrefslogtreecommitdiffstats
path: root/hugolib/page_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-28 10:21:54 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-28 10:28:50 +0100
commit7540a62834d4465af8936967e430a9e05a1e1359 (patch)
tree081ac01fd4ba3ce125825eb40cfbb5911845dbec /hugolib/page_test.go
parent7e75aeca80aead50d64902d2ff47e4ad4d013352 (diff)
parser/pageparser: Fix handling of commented out front matter
When the page parser was rewritten in 0.51, this was interpreted literally, but commented out front matter is used in the wild to "hide it from GitHub", e.g: ``` <!-- +++ title = "hello" +++ --> ``` Fixes #5478
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r--hugolib/page_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index f9c26754b..cd8bd8ffc 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1586,6 +1586,33 @@ CONTENT:{{ .Content }}
)
}
+// https://github.com/gohugoio/hugo/issues/5478
+func TestPageWithCommentedOutFrontMatter(t *testing.T) {
+ b := newTestSitesBuilder(t)
+ b.WithSimpleConfigFile()
+
+ b.WithContent("page.md", `<!--
++++
+title = "hello"
++++
+-->
+This is the content.
+`)
+
+ b.WithTemplatesAdded("layouts/_default/single.html", `
+Title: {{ .Title }}
+Content:{{ .Content }}
+`)
+
+ b.CreateSites().Build(BuildCfg{})
+
+ b.AssertFileContent("public/page/index.html",
+ "Title: hello",
+ "Content:<p>This is the content.</p>",
+ )
+
+}
+
// TODO(bep) this may be useful for other tests.
func compareObjects(a interface{}, b interface{}) bool {
aStr := strings.Split(fmt.Sprintf("%v", a), "")