Cellarius wrote a really good article that you may be interested in -
[vB4] Rendering templates and registering variables - a short guide Near the bottom he talks about how to preregister a variable for use in a template (search on the word preregister).
If you are creating a variable that is a bunch of table rows (you are using .= to add to the variable?), then once you are out of the loop you will want to preregister the variable for use in a template. If you are rendering the template in the middle of the loop, then you would just use $templater->register right before you render it.