How to use .Scratch.Get in subpartial templates

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.

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 }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.