refactoring generate_single_item_view and generate_list_view in API