Calling $.Scratch from within partial : can't evaluate field Scratch in type goldmark.imageLinkContext

I can’t set a .scratch value from within a partial.

{{ $.Scratch.Set srcset (delimit $src , ) }}
{{ $.Scratch.Set home_medium $medium.RelPermalink }}

gives

Error: error building site: “/home/drm/WEBSITE/content/docs/Biology/fallen.md:1:1”: “/home/drm/WEBSITE/layouts/_default/_markup/render-image.html:76:4”: execute of template failed: template: _default/_markup/render-image.html:76:4: executing “_default/_markup/render-image.html” at <partial “WithFigure” .>: error calling partial: execute of template failed: template: home/_markup/render-image.html:72:4: executing “partials/WithFigure” at <partial “ImagePartial” .>: error calling partial: execute of template failed: template: home/_markup/render-image.html:60:5: executing “partials/ImagePartial” at <$.Scratch.Set>: can’t evaluate field Scratch in type goldmark.imageLinkContext

I read the previous post .Scratch within partial range but it did not actually provide an answer, as to of why the OP couldn’t retrieve a scratch value set inside a partial. But maybe it’s unrelated since he could set it, not get it, my case seems to be opposite.

My code lies within {{ define "partials/ImagePartial" }}, inside “/layouts/home/_markup/render-image.html”, called only for the homepage.

Try $.Page.Scratch instead

Ah, I forgot…
I don’t understand when or where we need to precise this, especially since Scratch is either local (with newscratch) or scoped to the page, so I don’t understand how there could ever be a confusion with something else here ?

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