Add a way to merge pages by language

As an example:

```html
{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
```

Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.

Fixes #4463
This commit is contained in:
Bjørn Erik Pedersen
2018-03-15 09:37:30 +01:00
parent 91fb8f1b59
commit ffaec4ca8c
13 changed files with 571 additions and 45 deletions

View File

@@ -1069,6 +1069,7 @@ func createMultiTestSitesForConfig(t *testing.T, siteConfig testSiteConfig, conf
mf := siteConfig.Fs
// TODO(bep) cleanup/remove duplication, use the new testBuilder in testhelpers_test
// Add some layouts
if err := afero.WriteFile(mf,
filepath.Join("layouts", "_default/single.html"),
@@ -1368,7 +1369,7 @@ func readSource(t *testing.T, fs *hugofs.Fs, filename string) string {
}
func readFileFromFs(t testing.TB, fs afero.Fs, filename string) string {
filename = filepath.FromSlash(filename)
filename = filepath.Clean(filename)
b, err := afero.ReadFile(fs, filename)
if err != nil {
// Print some debug info