I’ve been tinkering on this for the past hour, but can’t get it to work.
I’m trying to pass a variable, $pages
, to a partial with dict
.
In layouts/product/list.html
, I have:
{{$pages := where .Pages "Layout" "==" ""}}
{{partial "products/list.html" (dict "products" $pages)}}
Then in partials/products/list.html
, I have:
{{range .products}}
{{$images := ($.Site.GetPage "/products/images").Resources}}
{{$img := $images.GetMatch (printf "%s.*" (anchorize .Title))}}
<img src="{{with $img}} {{.RelPermalink}} {{end}}"/>
{{end}}
This will not work. But doing the following does:
In layouts/product/list.html
:
{{partial "products/list.html" .}}
Then in partials/products/list.html
:
{{$pages := where .Pages "Layout" "==" ""}}
{{range $pages}}
{{$images := ($.Site.GetPage "/products/images").Resources}}
{{$img := $images.GetMatch (printf "%s.*" (anchorize .Title))}}
<img src="{{with $img}} {{.RelPermalink}} {{end}}"/>
{{end}}
What am I missing?