guard templates with the if directive where necessary