Hello. Help me please with my error. I have the error contain with .Scratch.Get.
Public Repo: https://github.com/igramnet/test-hugo
ERROR 2021/10/04 16:12:56 Failed to render pages: render of “home” failed: execute of template failed: template: index.html:2:3: executing “index.html” at <partial “modules/map/map-def” .>: error calling partial: execute of template failed: template: partials/modules/map/map-def.html:54:19: executing “partials/modules/map/map-def.html” at <partial “modules/map/map-list-column” .>: error calling partial: execute of template failed: template: partials/modules/map/map-list-column.html:74:31: executing “partials/modules/map/map-list-column.html” at <partial “modules/map/map-list-column-data” $contentData>: error calling partial: “c:\Pavel\servers\test\themes\test\layouts\partials\modules\map\map-list-column-data.html:1:23”: execute of template failed: template: partials/modules/map/map-list-column-data.html:1:23: executing “partials/modules/map/map-list-column-data.html” at <.Scratch.Get>: can’t evaluate field Scratch in type string
Here, you didnt pass current .Page
context / the .
(dot) when calling modules/map/map-list-column-data
partial.
{{ $countryName = .country }}
{{ end }}
{{ if eq $paramProduct "host" }}
{{ $.Scratch.Set "isHost" 1 }}
{{ $.Scratch.Set "hostingType" .hosting_type }}
{{ else }}
{{ $.Scratch.Set "isHost" 0 }}
{{ end }}
{{ $.Scratch.Set "countryName" $countryName }}
{{ partial "modules/map/map-list-column-data" $contentData }}
{{ $.Scratch.Delete "isHost" }}
{{ if eq $paramProduct "host" }}
{{ $.Scratch.Delete "hostingType" }}
{{ end }}
{{ $.Scratch.Delete "countryName" }}
{{ end }}
{{ end }}
{{ $contentData }}
{{ range $index, $value := sort $list ".country" "asc" }}
That’s why .Scratch
is not available inside that partial.
EDIT
after analyzing your template, you declare $contentData
variable but never set any data to it, why would you pass it to partials/modules/map/map-list-column-data.html
?
Inside partials/modules/map/map-list-column-data.html
you also never call the .
(passed $contentData
from parent partial).
Looks like you only need to call the Page .Scratch
.
Then do this, on partials/modules/map/map-list-column.html
,
++{{ partial "modules/map/map-list-column-data" $ }}
--{{ partial "modules/map/map-list-column-data" $contentData }}
system
Closed
October 6, 2021, 2:01pm
3
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.