Node.pool variable not working in task template

Nomad version: 1.6.1

template {
data = <<EOH
{{ with nomadVar “/nomad/jobs/<>_job/<>_group/<>_task” }}
{{ $NODEPOOL:=env “node.pool” }}
{{- range $kk, $vv := . }}
{{if eq $kk $NODEPOOL}}
DOMAIN={{ $vv }}
{{ end }}
{{- end }}
{{- end }}
EOH
destination = “secrets/env.txt”
env = true
}

Same template works fine with node.class, for example
template {
data = <<EOH
{{ with nomadVar “/nomad/jobs/<>_job/<>_group/<>_task” }}
{{ $NODECLASS:=env “node.class” }}
{{- range $kk, $vv := . }}
{{if eq $kk $NODECLASS}}
DOMAIN={{ $vv }}
{{ end }}
{{- end }}
{{- end }}
EOH
destination = “secrets/env.txt”
env = true
}