mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
Add tpl/site and tpl/hugo
This means that the current `.Site` and ´.Hugo` is available as a globals, so you can do `site.IsServer`, `hugo.Version` etc. Fixes #5470 Fixes #5467 Fixes #5503
This commit is contained in:
@@ -236,3 +236,24 @@ Page Content
|
||||
b.AssertFileContent("public/page/index.html", "Base: Hi!?")
|
||||
|
||||
}
|
||||
|
||||
func TestTemplateFuncs(t *testing.T) {
|
||||
|
||||
b := newTestSitesBuilder(t).WithDefaultMultiSiteConfig()
|
||||
|
||||
homeTpl := `Site: {{ site.Language.Lang }} / {{ .Site.Language.Lang }} / {{ site.BaseURL }}
|
||||
Hugo: {{ hugo.Generator }}
|
||||
`
|
||||
|
||||
b.WithTemplatesAdded(
|
||||
"index.html", homeTpl,
|
||||
"index.fr.html", homeTpl,
|
||||
)
|
||||
|
||||
b.CreateSites().Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/en/index.html", "Site: en / en / http://example.com/blog",
|
||||
"Hugo: <meta name=\"generator\" content=\"Hugo")
|
||||
b.AssertFileContent("public/fr/index.html", "Site: fr / fr / http://example.com/blog")
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user