add recursive template support

add recursive template support