From eef23a7f2762ac2875da14a432f4700c43d58deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 2 Mar 2023 09:37:07 +0100 Subject: Fix "page" not defined Fixes #10774 --- tpl/templates/integration_test.go | 26 ++++++++++++++++++++++++++ tpl/tplimpl/template_funcs.go | 1 + 2 files changed, 27 insertions(+) diff --git a/tpl/templates/integration_test.go b/tpl/templates/integration_test.go index fea2d7f6e..d6ea9228d 100644 --- a/tpl/templates/integration_test.go +++ b/tpl/templates/integration_test.go @@ -83,3 +83,29 @@ post/doesnotexist.html: false `) } + + +// See #10774 +func TestPageFunctionExists(t *testing.T) { + t.Parallel() + + files := ` +-- config.toml -- +baseURL = 'http://example.com/' +-- layouts/index.html -- +Home: {{ page.IsHome }} + +` + + b := hugolib.NewIntegrationTestBuilder( + hugolib.IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/index.html", ` +Home: true + +`) +} diff --git a/tpl/tplimpl/template_funcs.go b/tpl/tplimpl/template_funcs.go index b8102c75d..1979fa1c9 100644 --- a/tpl/tplimpl/template_funcs.go +++ b/tpl/tplimpl/template_funcs.go @@ -50,6 +50,7 @@ import ( _ "github.com/gohugoio/hugo/tpl/math" _ "github.com/gohugoio/hugo/tpl/openapi/openapi3" _ "github.com/gohugoio/hugo/tpl/os" + _ "github.com/gohugoio/hugo/tpl/page" _ "github.com/gohugoio/hugo/tpl/partials" _ "github.com/gohugoio/hugo/tpl/path" _ "github.com/gohugoio/hugo/tpl/reflect" -- cgit v1.2.3