summaryrefslogtreecommitdiffstats
path: root/hugolib/resource_chain_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-02 17:35:33 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-02 23:54:16 +0300
commit10ac2ec4466090957e1f6897906ddeb1e0b13673 (patch)
treec0d6c875a2305a6e0dc2c6bdc30dcf8fc8253893 /hugolib/resource_chain_test.go
parentce264b936ce9f589bd889e18762881cff8bc9cd0 (diff)
tpl/collections: Fix handling of different interface types in Slice
In Hugo `0.49` we improved type support in `slice`. This has an unfortunate side effect in that `resources.Concat` now expects something that can resolve to `resource.Resources`. This worked for most situations, but when you try to `slice` different `Resource` objects, you would be getting `[]interface {}` and not `resource.Resources`. And `concat` would fail: ```bash error calling Concat: slice []interface {} not supported in concat. ``` This commit fixes that by simplifying the type checking logic in `Slice`: * If the first item implements the `Slicer` interface, we try that * If the above fails or the first item does not implement `Slicer`, we just return the `[]interface {}` Fixes #5269
Diffstat (limited to 'hugolib/resource_chain_test.go')
-rw-r--r--hugolib/resource_chain_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go
index 045c9517a..1f55976f0 100644
--- a/hugolib/resource_chain_test.go
+++ b/hugolib/resource_chain_test.go
@@ -238,6 +238,10 @@ T1: Content: {{ $combined.Content }}|RelPermalink: {{ $combined.RelPermalink }}|
{{ $combinedText := . | resources.Concat "bundle/concattxt.txt" }}
T2: Content: {{ $combinedText.Content }}|{{ $combinedText.RelPermalink }}
{{ end }}
+{{/* https://github.com/gohugoio/hugo/issues/5269 */}}
+{{ $css := "body { color: blue; }" | resources.FromString "styles.css" }}
+{{ $minified := resources.Get "css/styles1.css" | minify }}
+{{ slice $css $minified | resources.Concat "bundle/mixed.css" }}
`)
}, func(b *sitesBuilder) {
b.AssertFileContent("public/index.html", `T1: Content: ABC|RelPermalink: /bundle/concat.txt|Permalink: http://example.com/bundle/concat.txt|MediaType: text/plain`)