What you’re trying to do is an unsafe operation. Go Templates will not allow you to output a PHP script in a HTML class attribute and it’s for a good reason.
But why are you trying to do the above? Maybe there is another way…
I know for a fact that hugo is for generating static pages but since it provided a way to output php too I am using it to output both php and html files. And while using it for such I encountered this need.