Skip to content

Commit 5fec782

Browse files
committed
tpl: Add some more test cases
See #13672 See #13668
1 parent 927d1ec commit 5fec782

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

‎tpl/tplimpl/templatestore_integration_test.go‎

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,61 @@ func TestTemplateLoopBlogVsBlogrollIssue13672(t *testing.T) {
14011401
t.Parallel()
14021402
files := `
14031403
-- hugo.toml --
1404+
-- layouts/blog/_shortcodes/myshortcode.html --
1405+
layouts/blog/_shortcodes/myshortcode.html
1406+
-- layouts/blog/baseof.html --
1407+
blog/baseof.html {{ block "main" . }}{{ end }}
14041408
-- layouts/blog/all.html --
1405-
blog/all.html
1409+
{{ define "main" }}blog/all.html|{{ .Content}}{{ end }}
1410+
-- layouts/blogroll/_shortcodes/myshortcode.html --
1411+
layouts/blogroll/myshortcode.html
1412+
-- layouts/blogroll/baseof.html --
1413+
{{ block "main" . }}blogroll/baseof.html{{ end }}
14061414
-- layouts/blogroll/all.html --
1407-
blogroll/all.html
1415+
{{ define "main" }}blogroll/all.html|{{ .Content}}{{ end }}
1416+
-- content/blog/p1.md --
1417+
---
1418+
title: p1
1419+
---
1420+
{{< myshortcode >}}
14081421
-- content/blogroll/p1.md --
1422+
---
1423+
title: p1
1424+
---
1425+
{{< myshortcode >}}
1426+
`
1427+
1428+
b := hugolib.Test(t, files)
1429+
1430+
b.AssertFileContent("public/blog/p1/index.html", "blog/baseof.html blog/all.html|layouts/blog/_shortcodes/myshortcode.html")
1431+
b.AssertFileContent("public/blogroll/p1/index.html", "blogroll/all.html|layouts/blogroll/myshortcode.html")
1432+
}
1433+
1434+
// See issue #13668.
1435+
func TestPartialPlainTextVsHTML(t *testing.T) {
1436+
t.Parallel()
1437+
1438+
/*
1439+
Note that in the below, there's no output format named txt,
1440+
so the isPlainText is fetched from the only output format with that extension.
1441+
*/
1442+
files := `
1443+
-- hugo.toml --
1444+
-- layouts/_partials/myhtml.html --
1445+
<div>myhtml</div>
1446+
-- layouts/_partials/mytext.txt --
1447+
<div>mytext</div>
1448+
-- layouts/all.html --
1449+
myhtml: {{ partial "myhtml.html" . }}
1450+
mytext: {{ partial "mytext.txt" . }}
1451+
mytexts|safeHTML: {{ partial "mytext.txt" . | safeHTML }}
14091452
`
14101453

14111454
b := hugolib.Test(t, files)
14121455

1413-
b.AssertFileContent("public/blogroll/p1/index.html", "blogroll/all.html")
1456+
b.AssertFileContent("public/index.html",
1457+
"myhtml: <div>myhtml</div>",
1458+
"mytext: &lt;div&gt;mytext&lt;/div&gt;",
1459+
"mytexts|safeHTML: <div>mytext</div>",
1460+
)
14141461
}

0 commit comments

Comments
 (0)