I have a template that needs to test .Content to know if a particular shortcode was used within. The intent is to keep the template from duplicating the image that the shortcode adds to the content. I tried introducing a .Scratch variable inside the shortcode and testing it in the template, but .Scratch doesn’t seem to be in-scope when I test?
The template reads like this:
{{ if not ( eq (.Scratch.Get "leaf-bug") "true" ) }}
<img class="leaf" src="/images/rootstalk_leaf.svg" />
{{ end }}
The shortcode like this:
<img class="leaf" src="/images/rootstalk_leaf.svg" />
{{ .Scratch.Set "leaf-bug" "true" }}
Can anyone suggest a mechanism to implement a test like this? Thanks in advance.