No Scratch functionality in Index?


#1

I tried using the scratch functionality inside a partial in my index, and no matter what it always returned as nothing. I tried as a string, integer, and float. This leads me to believe that there is no “Scratch” on an index page because it’s not a “page”?


#2

“Everything” is a page and have a scratch. But make sure you pass the index page to the partial.


#3

Here’s my partial declaration
{{ partial "project-group" (dict "meta" . "group" "animation") }}

And these are the lines inside the partial using the scratch
{{ $.Scratch.Set "string" "string" }} {{ $string := $.Scratch.Get "string" }}

And inside a range in the partial (which has its own internal context)
{{ $string }}

Do I need to be using .meta when using my scratch? I thought that’s what the $ was for?

Thank you for your time.


#4

Yes…


#5

The $. syntax is a way to refer to the outermost context, to avoid confusion when inside a range etc. In your case that would be the map created from the dict func, and not the object containing the Scratch.


#6

Oh okay, that makes sense! Thank you so much!