In a template, how do you get a variable to be valable declared outside (in top of the file) define blocks, be valable inside them ?
I know I can pass on a context to partials/blocks, but I would rather avoid it. It’s unnatural and adds a lot of complication, compared to the simpler variable (or scratch) syntax.
I just need a “global” variable, valid inside a whole template. Something like the following, if it worked:
{{ $all-class := "" }}
{{ range .Site.Data.drafts.note }}
{{ $all-class = uniq (slice $all-class .class) }}
{{ end }}
{{ define "specific-head" }}
<style>
h4, h4+div {
content-visibility: hidden
}
menu.labels {
display: flex; flex-wrap: wrap;
place-content: space-evenly;
}
{{ range $all-class }}
input#{{.}}_input:checked ~ .{{.}},
input#{{.}}_input:checked ~ .{{.}} + h4 {
content-visibility: visible;
}
{{ end }}
</style>
{{ end }}
{{ define "specific-content" }}
{{ range $all-class }}
<input type="checkbox" id="{{.}}_input">
{{end}}
{{ with .Site.Data.drafts }}
{{ range $all-class }}
<menu class=labels>
<label for="{{.}}_input">{{.}}</label>
</menu>
{{ end }}
{{ range .note }}
<h4 {{with .class}}class="{{delimit . " "}}"{{end}}>{{ .title | .RenderString }}</h4>
<div>{{ .content | .RenderString }}</div>
{{ end }}
{{ end }}
{{ end }}