Add support for pagination in view and template