ref: dd9344816a57586234e26554e06af331f16c0919
parent: 13d900940650040fa2b945449e235bade4ea751e
author: bep <bjorn.erik.pedersen@gmail.com>
date: Sun Feb 1 15:36:43 EST 2015
Scratch doc: Use the special $ variable to prevent confusion
--- a/docs/content/extras/scratch.md
+++ b/docs/content/extras/scratch.md
@@ -25,18 +25,20 @@
The usage is best illustrated with some samples:
```
-{{ .Scratch.Add "a1" 12 }}-{{ .Scratch.Get "a1" }} {{/* => 12 */}}-{{ .Scratch.Add "a1" 1 }}-{{ .Scratch.Get "a1" }} // {{/* => 13 */}}+{{ $.Scratch.Add "a1" 12 }}+{{ $.Scratch.Get "a1" }} {{/* => 12 */}}+{{ $.Scratch.Add "a1" 1 }}+{{ $.Scratch.Get "a1" }} // {{/* => 13 */}}-{{ .Scratch.Add "a2" "AB" }}-{{ .Scratch.Get "a2" }} {{/* => AB */}}-{{ .Scratch.Add "a2" "CD" }}-{{ .Scratch.Get "a2" }} {{/* => ABCD */}}+{{ $.Scratch.Add "a2" "AB" }}+{{ $.Scratch.Get "a2" }} {{/* => AB */}}+{{ $.Scratch.Add "a2" "CD" }}+{{ $.Scratch.Get "a2" }} {{/* => ABCD */}}-{{ .Scratch.Set "v1" 123 }}-{{ .Scratch.Get "v1" }} {{/* => 123 */}} +{{ $.Scratch.Set "v1" 123 }}+{{ $.Scratch.Get "v1" }} {{/* => 123 */}}```
+
+**Note:** The examples above uses the special `$` variable, which refers to the top-level node. This is the behavior you most likely want, and will help remove some confusion when using `Scratch` inside page range loops -- and you start inadvertently calling the wrong `Scratch`. But there may be use cases for `{{ .Scratch.Add "key" "some value" }}`.--
⑨