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

Skip to content

Don't apply nested page context handling to standalone .RenderShortcodes #14732

@bep

Description

@bep

The current tracking of nested page context (typically used for inclusion of content and having any relative links resolve correctly) assume that we're rendering content (either via Page.Content or Page.RenderString).

This means that the test below fails (the content never gets rendered to HTML, so the wrapper strings gets left behind).

See #12457 for a bigger discussion about this, but one use case for the below would be output format that just outputs ... Markdown.

And we should be able to detect and handle this scenario, as we already do similar checks.

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

	files := `
-- hugo.toml --
disableKinds = ['section','rss','sitemap','taxonomy','term']
-- layouts/all.html --
RenderShortcodes: {{ .RenderShortcodes }}|
-- layouts/_shortcodes/headings.html --
## Heading 1
### Heading 2
{{ $p := site.GetPage "includeme" }}
RenderShortcodes2: {{ $p.RenderShortcodes }}|
-- content/p1.md --
title: "p1"
---
{{% headings "headings" %}}
-- content/includeme.md --
---
title: "includeme"
---
## Heading 2
`

	b := Test(t, files)

	b.AssertNoRenderShortcodesArtifacts()
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions