Returning a string isn't a problem - look at adp_parse_template.
But the template engine expects the template to be stored in the file system ... you can't just pass a string to it (or two strings to it, script and adp).
How about storing the template in a temporary file system location and letting the template engine fetch it from there. A sweeper could clean up the directory once per day.