Fix issue with replace_template not working with error_handlers