Start cleanup of codegen templates addresses #6

Change all raw output lines to sprintf so that everything lives inside
php tags. This makes everything a bit easier to digest.

The main purpose for this pull request is to make sure we're happy with the way I'm approaching this. Check it out and let me know what you think.