mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
@@ -65,7 +65,8 @@ func TestSiteBuildErrors(t *testing.T) {
|
||||
fileFixer: func(content string) string {
|
||||
return strings.Replace(content, ".Title }}", ".Title }", 1)
|
||||
},
|
||||
assertCreateError: func(a testSiteBuildErrorAsserter, err error) {
|
||||
// Base templates gets parsed at build time.
|
||||
assertBuildError: func(a testSiteBuildErrorAsserter, err error) {
|
||||
a.assertLineNumber(4, err)
|
||||
},
|
||||
},
|
||||
@@ -90,7 +91,7 @@ func TestSiteBuildErrors(t *testing.T) {
|
||||
a.c.Assert(fe.Position().LineNumber, qt.Equals, 5)
|
||||
a.c.Assert(fe.Position().ColumnNumber, qt.Equals, 1)
|
||||
a.c.Assert(fe.ChromaLexer, qt.Equals, "go-html-template")
|
||||
a.assertErrorMessage("\"layouts/_default/single.html:5:1\": parse failed: template: _default/single.html.___b:5: unexpected \"}\" in operand", fe.Error())
|
||||
a.assertErrorMessage("\"layouts/foo/single.html:5:1\": parse failed: template: foo/single.html:5: unexpected \"}\" in operand", fe.Error())
|
||||
|
||||
},
|
||||
},
|
||||
|
@@ -677,3 +677,46 @@ P3: Inline: p3
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/7478
|
||||
func TestBaseWithAndWithoutDefine(t *testing.T) {
|
||||
|
||||
b := newTestSitesBuilder(t)
|
||||
|
||||
b.WithContent("p1.md", "---\ntitle: P\n---\nContent")
|
||||
|
||||
b.WithTemplates(
|
||||
"_default/baseof.html", `
|
||||
::Header Start:{{ block "header" . }}{{ end }}:Header End:
|
||||
::{{ block "main" . }}Main{{ end }}::
|
||||
`, "index.html", `
|
||||
{{ define "header" }}
|
||||
Home Header
|
||||
{{ end }}
|
||||
{{ define "main" }}
|
||||
This is home main
|
||||
{{ end }}
|
||||
`,
|
||||
|
||||
"_default/single.html", `
|
||||
{{ define "main" }}
|
||||
This is single main
|
||||
{{ end }}
|
||||
`,
|
||||
)
|
||||
|
||||
b.CreateSites().Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/index.html", `
|
||||
Home Header
|
||||
This is home main
|
||||
`,
|
||||
)
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", `
|
||||
::Header Start::Header End:
|
||||
This is single main
|
||||
`,
|
||||
)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user