I just ran into a strange behaviour and I am not shure where the mistake is. I would like to use resources.FromString
and the string is generated within a range
. First the working example:
{{ $number := slice "1" "2" "3"}}
{{ $string := slice "a" }}
{{ range $character }}
{{ $string = $string | append "b" }}
{{ end }}
{{ $string = $string | append "c" }}
{{ $string = print (delimit $string "") }}
{{ printf "%T - %s" $string $string }}
{{- $targetPath := "css/generated.css" -}}
{{ $generated := $string | resources.FromString $targetPath | fingerprint }}
<link rel="stylesheet" href="{{ $generated.Permalink }}" integrity="{{ $generated.Data.Integrity }}">
The printed output is string - abbbc
and the content of generated.css is abbbc
. Ok, now I only change the range to use my categories .Site.Taxonomies.categories
(there are 3 as well):
{{ $number := slice "1" "2" "3"}}
{{ $string := slice "a" }}
{{ range .Site.Taxonomies.categories }}
{{ $string = $string | append "b" }}
{{ end }}
{{ $string = $string | append "c" }}
{{ $string = print (delimit $string "") }}
{{ printf "%T - %s" $string $string }}
{{ $targetPath := "css/generated.css" }}
{{ $generated := $string | resources.FromString $targetPath | fingerprint }}
<link rel="stylesheet" href="{{ $generated.Permalink }}" integrity="{{ $generated.Data.Integrity }}">
The printed output is again string - abbbc
. Fine. However, the content of generated.css is just ac
. So for some reason part of the string, which is generated with the range, gets lost in the resource.
Any suggestions?