Adding diazo middleware to process templates