Just as a personal style thing, I'd prefer if logic like this was outside of the template.