From f8c67f93e123a7ac1c9c7af8000cc9d1fd978cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 2 Jun 2020 18:08:17 +0200 Subject: Allow hook template per section/type Fixes #7349 --- hugolib/content_render_hooks_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'hugolib') diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go index f161a46a2..17d273a33 100644 --- a/hugolib/content_render_hooks_test.go +++ b/hugolib/content_render_hooks_test.go @@ -50,6 +50,7 @@ Inner Block: {{ .Inner | .Page.RenderString (dict "display" "block" ) }} b.WithTemplatesAdded("docs/_markup/render-link.html", `Link docs section: {{ .Text | safeHTML }}|END`) b.WithTemplatesAdded("_default/_markup/render-image.html", `IMAGE: {{ .Page.Title }}||{{ .Destination | safeURL }}|Title: {{ .Title | safeHTML }}|Text: {{ .Text | safeHTML }}|END`) b.WithTemplatesAdded("_default/_markup/render-heading.html", `HEADING: {{ .Page.Title }}||Level: {{ .Level }}|Anchor: {{ .Anchor | safeURL }}|Text: {{ .Text | safeHTML }}|END`) + b.WithTemplatesAdded("docs/_markup/render-heading.html", `Docs Level: {{ .Level }}|END`) b.WithContent("customview/p1.md", `--- title: Custom View @@ -133,7 +134,15 @@ some text ## Heading Level 2 ### Heading Level 3 -`) +`, + "docs/p8.md", `--- +title: Doc With Heading +--- + +# Docs lvl 1 + +`, + ) for i := 1; i <= 30; i++ { // Add some content with no shortcodes or links, i.e no templates needed. @@ -146,7 +155,7 @@ title: No Template } counters := &testCounters{} b.Build(BuildCfg{testCounters: counters}) - b.Assert(int(counters.contentRenderCounter), qt.Equals, 44) + b.Assert(int(counters.contentRenderCounter), qt.Equals, 45) b.AssertFileContent("public/blog/p1/index.html", `

Cool Page|https://www.google.com|Title: Google's Homepage|Text: First Link|END

@@ -194,6 +203,10 @@ SHORT3| b.AssertFileContent("public/blog/p4/index.html", `IMAGE EDITED: /images/Dragster.jpg|`) b.AssertFileContent("public/blog/p6/index.html", "

Inner Link: EDITED: https://www.gohugo.io|

") b.AssertFileContent("public/blog/p7/index.html", "HEADING: With Headings||Level: 1|Anchor: heading-level-1|Text: Heading Level 1|END

some text

\nHEADING: With Headings||Level: 2|Anchor: heading-level-2|Text: Heading Level 2|ENDHEADING: With Headings||Level: 3|Anchor: heading-level-3|Text: Heading Level 3|END") + + // https://github.com/gohugoio/hugo/issues/7349 + b.AssertFileContent("public/docs/p8/index.html", "Docs Level: 1") + } func TestRenderHooksDeleteTemplate(t *testing.T) { -- cgit v1.2.3