add recursive template support