Hello all,
it’s my first post here.
I have an issue when i try to get .Params value in a range embedded in a with clause. Here’s the code
{{ with .Site.GetPage “page” “consulting.fr.md” }}
<div class="col-main">
<h2 class="with-sub">{{ .Title }}</h2>
<p>{{ .Description }}</p>
</div>
{{ range $index, $value := .Params.benefits_text }}
<div class="col-benefit">
<img src="{{ $.Site.BaseURL }}{{ index .Params.benefits_icon $index }}" alt="">
<p>{{ $value }}</p>
</div>
{{ end }}
{{ end }}
</div>
The {{ index .Params.benefits_icon $index }} return an error. it seems the scope change and i only find one way to have no error by using a $current var instead with.
{{ $current := .Site.GetPage “page” “consulting.fr.md” }}
<div class="col-main">
<h2 class="with-sub">{{ $current.Title }}</h2>
<p>{{ $current.Description }}</p>
</div>
{{ range $index, $value := $current.Params.benefits_text }}
<div class="col-benefit">
<img src="{{ $.Site.BaseURL }}{{ index $current.Params.benefits_icon $index }}" alt="">
<p>{{ $value }}</p>
</div>
{{ end }}
</div>
Is there another way to keep the scope on the page called by the with clause ? Thank you for your help !