One way is to register a custom function which dereferences the pointer, so you can compare the result to whatever you want to or do anything else with it.
For example:
func main() {
t := template.Must(template.New("").Funcs(template.FuncMap{
"Deref": func(i *int) int { return *i },
}).Parse(src))
i := 5
m := map[string]interface{}{"ID": &i}
if err := t.Execute(os.Stdout, m); err != nil {
fmt.Println(err)
}
}
const src = `{{if eq 5 (Deref .ID)}}It's five.{{else}}Not five: {{.ID}}{{end}}`
Output:
It's five.
Alternatively you could use a different custom function which would take a pointer and a non-pointer, and do the comparision, e.g.:
"Cmp": func(i *int, j int) bool { return *i == j },
And calling it from the template:
{{if Cmp .ID 5}}It's five.{{else}}Not five: {{.ID}}{{end}}
Output is the same. Try these on the Go Playground.