diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-07-06 14:12:10 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-07-06 17:51:38 +0200 |
commit | 2b8d907ab731627f4e2a30442cd729064516c8bb (patch) | |
tree | 2f9235dfbcf116c463b75d59c8be1be53d55b05a /hugolib/page_test.go | |
parent | 43338c3a99769eb7d0df0c12559b8b3d42b67dba (diff) |
Add a newScratch template func
Fixes #4685
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r-- | hugolib/page_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 985373a90..b512a9a5a 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -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") |