gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75k stars 7.47k forks source link

content adapter: Shortcode not rendered unless preceded by character #12544

Closed jmooring closed 4 months ago

jmooring commented 4 months ago

Reference: https://discourse.gohugo.io/t/50052

This works:

{{ $content := dict "mediaType" "text/markdown" "value" "x{{< sc >}}" }}

This does not (nothing is rendered):

{{ $content := dict "mediaType" "text/markdown" "value" "{{< sc >}}" }}

Test case:

func TestFoo(t *testing.T) {
    t.Parallel()

    files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- content/_content.gotmpl --
{{ $content := dict "mediaType" "text/markdown" "value" "x{{< sc >}}" }}
{{ .AddPage (dict "content" $content "path" "a") }}

{{ $content := dict "mediaType" "text/markdown" "value" "{{< sc >}}" }}
{{ .AddPage (dict "content" $content "path" "b") }}
-- layouts/_default/single.html --
{{ .Content }}|
-- layouts/shortcodes/sc.html --
foo
{{- /**/ -}}
`

    b := hugolib.Test(t, files)

    b.AssertFileContent("public/a/index.html", "<p>xfoo</p>")
    b.AssertFileContent("public/b/index.html", "<p>foo</p>") // fails
}
github-actions[bot] commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.