Hello,
I have an edge case i think.
I cannot make .Resources.GetMatch work in a partial.
I want to make “content_de/invoices/content3.md” have it’s own resources, and load them in a partial.
The example is bellow.
Thanks in advance!
Hello,
I have an edge case i think.
I cannot make .Resources.GetMatch work in a partial.
I want to make “content_de/invoices/content3.md” have it’s own resources, and load them in a partial.
The example is bellow.
Thanks in advance!
@regis thanks for the feedback.
I managed to make it work by passing the top context in the partial.
{{ with .Resources.ByType "page" }}
{{ range . }}
<h3>Template name {{ .Params.template }}</h3>
{{ $widget := (printf "%s%s" "page-builder/" .Params.template ) }}
{{ partial $widget (dict "pageScope" . "outerScope" $) }}
{{ end }}
{{ end }}
And in the partial i use:
{{ $image1 := .outerScope.Resources.GetMatch "img.jpg" }}
<h4>{{ .pageScope.Params.headline}}</h4>
{{ with $image1 }}
{{ $resized := $image1.Resize "40x" }}
{{ $resized.Permalink }}
{{ end}}
Hope this helps someone who want to create a page builder with Hugo.