Only merge valid templates.