Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.RenderShortcodes misbehaves when it's identified or inside a code block #12457

@bep

Description

@bep

If you in a "include" type of shortcode when using the {{% syntax to use it, indent the {{ $p.RenderShortcodes }} with 4 characters:

     {{ $p.RenderShortcodes }}

You end up with a {{__hugo_ctx pid=3214}} similar code in the output.

Note that I would say that the above is (almost?) always a signal to fix/adjust your template, and I'm not sure how/what the fix would be.

Failing test:

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

	files := `
-- hugo.toml --
disableKinds = ['section','rss','sitemap','taxonomy','term']
-- layouts/_shortcodes/foo.html --
{{ $p := site.GetPage "includeme" }}
    {{ $p.RenderShortcodes }}
-- layouts/home.html --
{{ .Content }}
-- content/_index.md --
---
title: home
---
{{% foo %}}
-- content/includeme.md --
---
title: "includeme"
---
Some markdown.
	`

	b := Test(t, files)
	b.AssertNoRenderShortcodesArtifacts()
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions