Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-04-23 14:40:05 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-04-23 16:04:35 +0300
commit0d86a32d8f3031e2124c8005b680b597f3c0e558 (patch)
treeebf2d60b31c3389480b8c2b87f0e06e9b1b734cd /hugolib/shortcode_test.go
parent65c502cc8110e49540cbe2b49ecd5a8ede9e67a1 (diff)
Make the shortcode template lookup for output formats stable
Fixes #7774
Diffstat (limited to 'hugolib/shortcode_test.go')
-rw-r--r--hugolib/shortcode_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
index bce95b527..41f4eddb5 100644
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -1347,3 +1347,49 @@ title: "No Inner!"
err := b.BuildE(BuildCfg{})
b.Assert(err.Error(), qt.Contains, `failed to extract shortcode: shortcode "noinner" has no .Inner, yet a closing tag was provided`)
}
+
+func TestShortcodeStableOutputFormatTemplates(t *testing.T) {
+ t.Parallel()
+
+ for i := 0; i < 5; i++ {
+
+ b := newTestSitesBuilder(t)
+
+ const numPages = 10
+
+ for i := 0; i < numPages; i++ {
+ b.WithContent(fmt.Sprintf("page%d.md", i), `---
+title: "Page"
+outputs: ["html", "css", "csv", "json"]
+---
+{{< myshort >}}
+
+`)
+ }
+
+ b.WithTemplates(
+ "_default/single.html", "{{ .Content }}",
+ "_default/single.css", "{{ .Content }}",
+ "_default/single.csv", "{{ .Content }}",
+ "_default/single.json", "{{ .Content }}",
+ "shortcodes/myshort.html", `Short-HTML`,
+ "shortcodes/myshort.csv", `Short-CSV`,
+ )
+
+ b.Build(BuildCfg{})
+
+ //helpers.PrintFs(b.Fs.Destination, "public", os.Stdout)
+
+ for i := 0; i < numPages; i++ {
+ b.AssertFileContent(fmt.Sprintf("public/page%d/index.html", i), "Short-HTML")
+ b.AssertFileContent(fmt.Sprintf("public/page%d/index.csv", i), "Short-CSV")
+ b.AssertFileContent(fmt.Sprintf("public/page%d/index.json", i), "Short-HTML")
+
+ }
+
+ for i := 0; i < numPages; i++ {
+ b.AssertFileContent(fmt.Sprintf("public/page%d/styles.css", i), "Short-HTML")
+ }
+
+ }
+}