It's better to move as much PHP code to the client instead of doing this in the view. I'm currently trying to rewrite the rest of the view to follow the same rule