generate as tpl code