Assuming that you have the $resource object with getObject(), this will get you an array of the TV objects:
$tvs = $resource->getMany('TemplateVars');
If it’s the current page, you don’t have to get it and can use this instead:
$modx->resource->getMany('TemplateVars');
Then you can get the names with:
foreach ($tvs as $tv) {
$tvName = $tv->get('name');
}