You need to render your template first and then assign it to the template_hook. Cellarius wrote a really good article that you may be interested in -
[vB4] Rendering templates and registering variables - a short guide
Example from his tutorial:
PHP Code:
All your code up here, and then....
/* render template and register variables */
$templater = vB_Template::create('mytemplate');
$templater->register('my_var', $my_var);
$templater->register('my_array', $my_array);
$template_hook['profile_sidebar_stats'] .= $templater->render();