Added Template compatibility to view generator.

Updated some code in the View generator to be compatible with templates.