refine fn_tpl
implement loop sample in user_inbox, and fix tpl_apply() and _tpl_set_array() too