I have the following template code which works correctly when I put it in the index.html
file in the layouts/
folder. However, when I make it into a partial template, it fails with can't evaluate field Pages in type []interface {}
.
{{ $ptypes := $.Site.Taxonomies.length }}
{{ $posts := ($ptypes.short | union $ptypes.long | union $ptypes.verylong).Pages }}
{{ if $.IsHome }}
{{ $posts = $ptypes.long.Pages }}
{{ end }}
{{ range $posts.GroupByDate "2006" }}
<ul>
<h3>{{ .Key }}</h3>
{{ range .Pages }}
<li>{{ partial "post-listing" . }}</li>
{{ end }}
</ul>
{{ end }}
As far as I can make out I have used the $
variable to ensure that gobal variables brought forward correctly. What is going wrong here?