Amazingly enough the templating system is able to do that. Here's a snippet from a working page that requests the survey results page for each user in a loop and writes it to a file. Note that this uses ns_set to manipulate the form values instead of rp_form_put because the latter just appends to existing values, which would break after the second iteration.
foreach survey_id $survey_ids {
set form [rp_getform]
ns_set delkey $form survey_id
ns_set put $form survey_id 3310
ns_set delkey $form user_id
ns_set put $form user_id $person_id
set parsed_template [template::adp_parse "[acs_root_dir]/packages/survey/www/admin/one-respondent" {}]
db_release_unused_handles
set f [open "$user_dir/survey_${survey_id}.html" w]
puts $f $parsed_template
close $f
}
No idea of the db_release_unused_handles call is necessary, I'm not sure if it solved the problem that once came up but it doesn't hurt so I left it in.