diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-02 13:52:08 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-02 13:52:08 +0100 |
commit | 5a94e4cfb9e765d5991ed4a4086f212f2829f1f0 (patch) | |
tree | 25a5c5ec4708c97fc3464cc93bede554c9cf3632 /hugolib/template_test.go | |
parent | f4779b25bc55a3b6693e9e3cbe6b2444fbf4e61b (diff) | |
download | hugo-5a94e4cfb9e765d5991ed4a4086f212f2829f1f0.tar.gz hugo-5a94e4cfb9e765d5991ed4a4086f212f2829f1f0.zip |
hugolib: Add section template baseof test case
Closes #2995
See #3116
Diffstat (limited to 'hugolib/template_test.go')
-rw-r--r-- | hugolib/template_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/hugolib/template_test.go b/hugolib/template_test.go index b508a9638..43608b7d4 100644 --- a/hugolib/template_test.go +++ b/hugolib/template_test.go @@ -141,6 +141,8 @@ func TestTemplateLookupOrder(t *testing.T) { func(t *testing.T) { cfg.Set("theme", "mytheme") + writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base: {{block "main" .}}block{{end}}`) + // Both single and list template in /SECTION/ writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "sect1", "list.html"), `sect list`) writeSource(t, fs, filepath.Join("themes", "mytheme", "layouts", "_default", "list.html"), `default list`) @@ -157,8 +159,41 @@ func TestTemplateLookupOrder(t *testing.T) { th.assertFileContent(filepath.Join("public", "sect2", "index.html"), "sect2 list") }, }, + { + // Test section list and single template selection with base template. + // Issue #2995 + func(t *testing.T) { + + writeSource(t, fs, filepath.Join("layouts", "_default", "baseof.html"), `Base Default: {{block "main" .}}block{{end}}`) + writeSource(t, fs, filepath.Join("layouts", "sect1", "baseof.html"), `Base Sect1: {{block "main" .}}block{{end}}`) + writeSource(t, fs, filepath.Join("layouts", "section", "sect2-baseof.html"), `Base Sect2: {{block "main" .}}block{{end}}`) + + // Both single and list + base template in /SECTION/ + writeSource(t, fs, filepath.Join("layouts", "sect1", "list.html"), `{{define "main"}}sect1 list{{ end }}`) + writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"), `{{define "main"}}default list{{ end }}`) + writeSource(t, fs, filepath.Join("layouts", "sect1", "single.html"), `{{define "main"}}sect single{{ end }}`) + writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), `{{define "main"}}default single{{ end }}`) + + // sect2 with list template in /section + writeSource(t, fs, filepath.Join("layouts", "section", "sect2.html"), `{{define "main"}}sect2 list{{ end }}`) + + }, + func(t *testing.T) { + th.assertFileContent(filepath.Join("public", "sect1", "index.html"), "Base Sect1", "sect1 list") + th.assertFileContent(filepath.Join("public", "sect1", "page1", "index.html"), "Base Sect1", "sect single") + th.assertFileContent(filepath.Join("public", "sect2", "index.html"), "Base Sect2", "sect2 list") + + // Note that this will get the default base template and not the one in /sect2 -- because there are no + // single template defined in /sect2. + th.assertFileContent(filepath.Join("public", "sect2", "page2", "index.html"), "Base Default", "default single") + }, + }, } { + if i != 9 { + continue + } + cfg, fs = newTestCfg() th = testHelper{cfg, fs, t} |