I want to use a variable from outside a template… in a different context within that template.
{{ $currLink := .URL }}
{{ range .Sections }}
{{ template "docplate" . }}
{{ end }}
{{ define "docplate" }}
{{ range .Pages }}
{{ if eq .Permalink $currLink }}
{{/* do something */}}
{{ end }}
{{ end }}
{{ end }}
Problem is, $currLink
is unavailable in the template
definition.
Scratch
doesn’t seem to work either. Is there a way to “pass” that variable for usage inside the template
?