I’m trying to use .Scratch in a range within a partial file. The goal is to set a .Scratch value outside of the range, change the scratch value in the range, then display the new value outside of the range. However, I can’t seem to even display the existing scratch value in the range.
In my main file, I’m using dict to pass context:
{{ partial "sections/build.html" (dict "c" . "g" $ ) }}`
In my partial file I’m able to set a scratch and display it properly. However, this doesn’t work within the range.
<!--. is .c-->
<!--$ is .g-->
{{ .g.Scratch.Set "number" "seven" }}
<!--displays seven correctly-->
{{ .g.Scratch.Get "number" }}
{{ range .c.row1 }}
<!--doesn't return anything-->
{{ .g.Scratch.Get "number" }}
{{ end }}
I know that I could set a variable equal to the scratch value and then display my scratch within the range this way. However, then I can’t reference the new scratch value outside of the range.