NAME
Template::Plugin::Bootstrap::Pagination - Produce HTML suitable for the Bootstrap pagination component
VERSION
version 0.002000
SYNOPSIS
use Template;
use Data::Page;
my $pagination_template_string = <<"EOTEMPLATE";
[%- USE Bootstrap.Pagination -%]
[%- Bootstrap.Pagination.pagination(pager = pager, uri = uri, version = 2) -%]
EOTEMPLATE
my $pager_template_string = <<"EOTEMPLATE";
[%- USE Bootstrap.Pagination -%]
[%- Bootstrap.Pagination.pager(pager = pager, uri = uri, version = 3) -%]
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();
DESCRIPTION
Template::Plugin::Bootstrap::Pagination is a plugin for Template::Toolkit which produces HTML compatible to the Bootstrap framework's pagination component.
METHODS
new
Constructor, creates a new instance of the plugin.
Parameters
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.
- context
-
A reference to the Template::Context which is loading the plugin. This is the positional parameter.
- version
-
Bootstrap version the HTML code should be generated for. Defaults to
2
for now, currently supported are the major versions2
and3
(although I have not tested many minor releases, so maybe this is not entirely correct). - uri
-
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. - pager
-
The Data::Page object the pager should be built with.
- prev_text
-
Text to use in the link to the previous page. Defaults to
«
. - next_text
-
Text to use in the link to the next page. Defaults to
»
. - offset
-
Offset to add to the page number. May be negative, which can be useful if the application's first page is
0
, not1
. Defaults to0
. - factor
-
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 to1
. - siblings
-
Number of links to display to the left and the right of the current page. Defaults to
3
. Only used in "pagination". - size
-
Size of the pagination component. Newer versions (starting at around 2.2.0) support sizing of the pager. Supports
large
,small
andmini
(mini
only in Bootstrap before 3.0.0 - will get mapped tosmall
if version is set to3
). - centered
-
If the pager should be centered. Defaults to
0
, i.e.false
. Only used in "pagination". - right
-
If the pager should be right aligned. Defaults to
0
, i.e.false
. Only used in "pagination". - align
-
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".
Result
The new instance.
pagination
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 | >
Parameters
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.
Result
The HTML code.
pager
Get HTML for a simple pager with only previous and next links.
Parameters
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.
Result
The HTML code.
SEE ALSO
http://getbootstrap.com/ - The Bootstrap framework, latest version
http://twitter.github.com/bootstrap/ - The Bootstrap framework, version 2.3.2
AUTHOR
Manfred Stock <mstock@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 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.