I do think this has too much logic in the view, and should be moved to a helper function, as you say.