Add a newScratch template func

Fixes #4685
This commit is contained in:
Bjørn Erik Pedersen
2018-07-06 14:12:10 +02:00
parent 43338c3a99
commit 2b8d907ab7
14 changed files with 319 additions and 231 deletions

View File

@@ -1830,6 +1830,33 @@ Summary: In Chinese, 好 means good.
}
func TestScratchSite(t *testing.T) {
t.Parallel()
b := newTestSitesBuilder(t)
b.WithSimpleConfigFile().WithTemplatesAdded("index.html", `
{{ .Scratch.Set "b" "bv" }}
B: {{ .Scratch.Get "b" }}
`,
"shortcodes/scratch.html", `
{{ .Scratch.Set "c" "cv" }}
C: {{ .Scratch.Get "c" }}
`,
)
b.WithContentAdded("scratchme.md", `
---
title: Scratch Me!
---
{{< scratch >}}
`)
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", "B: bv")
b.AssertFileContent("public/scratchme/index.html", "C: cv")
}
func BenchmarkParsePage(b *testing.B) {
s := newTestSite(b)
f, _ := os.Open("testdata/redis.cn.md")