},
}
- ps.shortcodeState = newShortcodeHandler(ps, ps.s)
-
if err := ps.mapContent(parentBucket, metaProvider); err != nil {
return nil, ps.wrapError(err)
}
// The parsed page content.
pageContent
+ // Keeps track of the shortcodes on a page.
+ shortcodeState *shortcodeHandler
+
// Set if feature enabled and this is in a Git repo.
gitInfo *gitmap.GitInfo
codeowners []string
cmap *pageContentMap
- shortcodeState *shortcodeHandler
-
source rawPageContent
}
},
}
+ ps.shortcodeState = newShortcodeHandler(ps, ps.s)
+
siteAdapter := pageSiteAdapter{s: s, p: ps}
ps.pageMenus = &pageMenus{p: ps}
"errors"
- "github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/text"
"github.com/gohugoio/hugo/common/types/hstring"
"github.com/gohugoio/hugo/identity"
}
func (p *pageContentOutput) RenderString(args ...any) (template.HTML, error) {
- defer herrors.Recover()
if len(args) < 1 || len(args) > 2 {
return "", errors.New("want 1 or 2 arguments")
}
)
})
+}
+
+// Issue 9959
+func TestRenderStringWithShortcodeInPageWithNoContentFile(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+-- layouts/shortcodes/myshort.html --
+Page Kind: {{ .Page.Kind }}
+-- layouts/index.html --
+Short: {{ .RenderString "{{< myshort >}}" }}
+Has myshort: {{ .HasShortcode "myshort" }}
+Has other: {{ .HasShortcode "other" }}
+
+ `
+
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/index.html",
+ `
+Page Kind: home
+Has myshort: true
+Has other: false
+`)
}