Template::Plugin::Bootstrap::Pagination - Produce HTML suitable for the Bootstrap pagination component
version 0.001000
use Template; use Data::Page; my $pagination_template_string = <<"EOTEMPLATE"; [%- USE Bootstrap.Pagination -%] [%- Bootstrap.Pagination.pagination(pager = pager, uri = uri) -%] EOTEMPLATE my $pager_template_string = <<"EOTEMPLATE"; [%- USE Bootstrap.Pagination -%] [%- Bootstrap.Pagination.pager(pager = pager, uri = uri) -%] EOTEMPLATE my $pager = Data::Page->new(42, 10, 2); my $uri = 'http://www.example.com/blog/__PAGE__.html'; my $template = Template->new(STRICT => 1); my $output; my $pagination_result = $template->process(\$pagination_template_string, { pager => $pager, uri => $uri, }, \$output) or die $template->error(); my $pager_result = $template->process(\$pager_template_string, { pager => $pager, uri => $uri, }, \$output) or die $template->error();
Template::Plugin::Bootstrap::Pagination is a plugin for Template::Toolkit which produces HTML compatible to the Bootstrap framework's pagination component.
Constructor, creates a new instance of the plugin.
This method expects its parameters as one positional parameter and an optional hash reference. The values passed in the hash reference will be used as default values, and can be overridden when calling the plugin's methods.
A reference to the Template::Context which is loading the plugin. This is the positional parameter.
Template for the URI to use in links. Any occurrence of __PAGE__ in the URI will be replaced by the page number it should point to. Please note that the URI will be entity encoded before adding it to the generated HTML.
__PAGE__
The Data::Page object the pager should be built with.
Text to use in the link to the previous page. Defaults to «.
«
Text to use in the link to the next page. Defaults to ».
»
Offset to add to the page number. May be negative, which can be useful if the application's first page is 0, not 1. Defaults to 0.
0
1
Factor to multiply the page number with. Can be useful if the application does not use pages, but offsets from eg. 0 (in that case, the factor will usually be the page size). Defaults to 1.
Number of links to display to the left and the right of the current page. Defaults to 3. Only used in "pagination".
3
If the pager should be centered. Defaults to 0, i.e. false. Only used in "pagination".
false
If the pager should be right aligned. Defaults to 0, i.e. false. Only used in "pagination".
Don't center previous and next links, align them to the sides instead. Defaults to 0, i.e. false, so the links will be centered. Only used in "pager".
The new instance.
Get HTML for a pagination. Includes a previous/next link, links to first and last page, and links to a range of pages around the current page:
< | 1 | ... | 8 | 9 | _10_ | 11 | 12 | ... | n | >
This method expects positional parameters. See "new" for the available parameters, their description and their defaults. pager and uri are required if they have not been passed to "new" as defaults.
pager
uri
The HTML code.
Get HTML for a simple pager with only previous and next links.
http://twitter.github.com/bootstrap/ - The bootstrap framework
Template::Toolkit
Manfred Stock <mstock@cpan.org>
This software is copyright (c) 2012 by Manfred Stock.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Template::Plugin::Bootstrap::Pagination, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Plugin::Bootstrap::Pagination
CPAN shell
perl -MCPAN -e shell install Template::Plugin::Bootstrap::Pagination
For more information on module installation, please visit the detailed CPAN module installation guide.