taking the template parser code into its own file