Add functionality to optionally provide a function instead of a class for view