summaryrefslogtreecommitdiffstats
path: root/hugolib/resource_chain_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-26 09:44:31 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-26 12:55:00 +0100
commit96f09659ce8752c32a2a6429c9faf23be4faa091 (patch)
treeba179894eddd24214697b98a19926c4f3c9a9b09 /hugolib/resource_chain_test.go
parent03b369e6726ed8a732c07db48f7209425c434bbe (diff)
Fix language handling in ExecuteAsTemplate
Fixes #6331
Diffstat (limited to 'hugolib/resource_chain_test.go')
-rw-r--r--hugolib/resource_chain_test.go30
1 files changed, 28 insertions, 2 deletions
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go
index 10539d1bb..9d869ba41 100644
--- a/hugolib/resource_chain_test.go
+++ b/hugolib/resource_chain_test.go
@@ -418,8 +418,7 @@ Fingerprinted: {{ $fingerprinted.RelPermalink }}
}},
{"execute-as-template", func() bool {
- // TODO(bep) eventually remove
- return isGo111()
+ return true
}, func(b *sitesBuilder) {
b.WithTemplates("home.html", `
{{ $var := "Hugo Page" }}
@@ -668,3 +667,30 @@ JSON: {{ $json.RelPermalink }}: {{ $json.Content }}
"JSON: /jsons/data1.json: json1 content",
"JSONS: 2", "/jsons/data1.json: json1 content")
}
+
+func TestExecuteAsTemplateWithLanguage(t *testing.T) {
+ b := newMultiSiteTestDefaultBuilder(t)
+ indexContent := `
+Lang: {{ site.Language.Lang }}
+{{ $templ := "{{T \"hello\"}}" | resources.FromString "f1.html" }}
+{{ $helloResource := $templ | resources.ExecuteAsTemplate (print "f%s.html" .Lang) . }}
+Hello1: {{T "hello"}}
+Hello2: {{ $helloResource.Content }}
+LangURL: {{ relLangURL "foo" }}
+`
+ b.WithTemplatesAdded("index.html", indexContent)
+ b.WithTemplatesAdded("index.fr.html", indexContent)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/en/index.html", `
+Hello1: Hello
+Hello2: Hello
+`)
+
+ b.AssertFileContent("public/fr/index.html", `
+Hello1: Bonjour
+Hello2: Bonjour
+`)
+
+}