I have a template and I would like to evaluate various fields using the text/template package. I have a hard to time to figure it out how the evaluation should work because the code below seems to fail. Is the template package powerful enough to handle this kind of evaluations?
type something struct{
Brand string
}
tpl := `{{if .Brand == "Coke"}} It's a coke{{else}} It's something else{{end}}`
There is a global function in the templates package named eq
that you can call. Not sure why it works like that but here is the code
type something struct{
Brand string
}
tpl := `{{if eq .Brand "Coke"}} It's a coke{{else}} It's something else{{end}}`