This is the kind of logic that usually should go in a template.