Move if clause to template