updated renderer to throw error if template is not valid