Move common logic to a base template.