Extracted the template rendering into a middleware module
Created deepEach underscore function to help with recursive object property iteration. Updated middleware to use it.